davedave24
Programmer
I have a workbook template that has 25 available rows where data from a userform is inserted. I use the following code to find the next empty row to write the data:
The layout has already been copied to 10 sheets (2 sheets will be enough but just in case). If the loop reaches row 57, instead of writing the data, it needs to move to the next sheet, and begin there. Obviously, sheet 2 may already have data in it, so another loop starting again at B32 finds the next blank line on sheet 2 to write the data. And so on, if it gets to row 57, it should move to sheet3, loop to the next empty line, write data, unless it gets to row 57, then it goes to sheet 4, and so forth.
I'm experimenting with ActiveCell.Row > 56 to try to force it to the next sheet, with little success. I don't want to have 10 nested If statements checking the row number for each sheet and moving to the next, so does anyone have a good way to do this with minimal code?
TIA!
Code:
myWorkbook.Worksheets("Sheet1").Range("B32").Select
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
Loop
The layout has already been copied to 10 sheets (2 sheets will be enough but just in case). If the loop reaches row 57, instead of writing the data, it needs to move to the next sheet, and begin there. Obviously, sheet 2 may already have data in it, so another loop starting again at B32 finds the next blank line on sheet 2 to write the data. And so on, if it gets to row 57, it should move to sheet3, loop to the next empty line, write data, unless it gets to row 57, then it goes to sheet 4, and so forth.
I'm experimenting with ActiveCell.Row > 56 to try to force it to the next sheet, with little success. I don't want to have 10 nested If statements checking the row number for each sheet and moving to the next, so does anyone have a good way to do this with minimal code?
TIA!