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
So if there's the number 10 in the spreadsheet's cell "B16", presently I end up with 10 rows looking something like this (sorry about the G-Code formatting)....
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?!