![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| G-Code Programing Discuss G-code programing and problems here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
I'll be blunt - I'm crap at programming....I've kludged a spreadsheet together which produces G-Code...but I want a Macro to run on this spreadsheet to extract some of the fields and assemble them automatically into G-Code lines - I'm almost there, but stuck with this little stumbling block (you must promise not to laugh as you see how I've done this!). I'm using the value of a number located in my spreadsheet cell (cell B16), to generate a number of Excel rows (which ultimately will contain CNC winder code when the Excel Macro is run)... Code: For counter = 1 To Range("B16")
Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 1)
CurCell.Value = "G01"
Next counter
For counter = 1 To Range("B16")
Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 2)
CurCell.Value = "X"
Next counter
For counter = 1 To Range("B16")
Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 3)
CurCell.Value = Range("B10").Value
Next counter
For counter = 1 To Range("B16")
Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 4)
CurCell.Value = "Y"
Next counter
For counter = 1 To Range("B16")
Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 5)
CurCell.Value = Range("B13").Value * counter
Next counter
For counter = 1 To Range("B16")
Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 6)
CurCell.Value = "F"
Next counter
For counter = 1 To Range("B16")
Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 7)
CurCell.Value = Range("B5").Value
Next counter G01 X 4.2371 Y 15.11677444 F 40 G01 X 4.2371 Y 30.23354888 F 40 G01 X 4.2371 Y 45.35032332 F 40 G01 X 4.2371 Y 60.46709776 F 40 G01 X 4.2371 Y 75.58387219 F 40 G01 X 4.2371 Y 90.70064663 F 40 G01 X 4.2371 Y 105.8174211 F 40 G01 X 4.2371 Y 120.9341955 F 40 G01 X 4.2371 Y 136.05097 F 40 G01 X 4.2371 Y 151.1677444 F 40 You can see that the X position remains constant - this is not what I want, read on.... I've bolded a blue section in the VBA code above, I really need that part of the VBA code to output an X coord number one line from the number sourced from cell B9 & the next G-Code line to have a X Coord sourced from cell B10...and alternate until the number of G-Code rows are finished. So for example, I'd like the output from the above code to look like this instead of the above G01 X 4.2371 Y 15.11677444 F 40 G01 X 0.263 Y 30.23354888 F 40 G01 X 4.2371 Y 45.35032332 F 40 G01 X 0.263 Y 60.46709776 F 40 G01 X 4.2371 Y 75.58387219 F 40 G01 X 0.263 Y 90.70064663 F 40 G01 X 4.2371 Y 105.8174211 F 40 G01 X 0.263 Y 120.9341955 F 40 G01 X 4.2371 Y 136.05097 F 40 G01 X 0.263 Y 151.1677444 F 40 (where the X coor number 0.263 is sourced from cell "B9" & the other X Coord number 4.2371 is sourced from cell "B10") Could some kind soul give me a pointer as to how I can approach this last bit of my quest?! |
|
#2
| ||||
| ||||
| How about this? For counter = 1 To Range("B16") step 2 Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 3) CurCell.Value = Range("B10").Value Next counter For counter = 2 To Range("B16") step 2 Set CurCell = Worksheets("Sheet1").Cells(counter + 36, 3) CurCell.Value = Range("B9").Value Next counter
__________________ Gerry Mach3 2010 Screenset http://home.comcast.net/~cncwoodworker/2010.html (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management) |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| macro in excel | mike9696 | Parametric Programing | 4 | 08-28-2009 05:44 PM |
| need help with excel vba macro | Timbersmith | G-Code Programing | 7 | 05-07-2008 07:46 PM |
| Fanuc OM tool change macro for a Kiwa/Excel | TR MFG | Fanuc | 5 | 01-27-2008 04:00 AM |
| 4 Axis CNC - MS Excel Source code (VBA) | arman | Visual Basic | 2 | 02-06-2007 04:27 AM |
| new post processor or excel macro or... | trubble2rubble | G-Code Programing | 3 | 07-16-2005 08:20 AM |