Use counter for line numbers?

  • Thread starter Thread starter Eva Shanley
  • Start date Start date
E

Eva Shanley

I have approximately 500 rows of data that need to be
transferred to Datacomm; Datacomm will only accept 99 rows
before it requires a different batch number, so I need to
count the rows from 1 to 99 then insert the respective row
numbers in each row. Then I need to start over again and
number from 1 to 99 for the next bunch of rows. I tried a
couple of macros and did get some results but they weren't
pretty; I could use some help on this. Thanks as always!
 
Enter a 1 in a cell. Right-click and fill down. Release and choose Series.
Enter a Stop value in the place provided. Click OK.
 
Try a loop like this. Just copy 'n Paste this into a
macro in the Visual Basic Editor:

Sub Counter()
Dim rowCntr As Integer, maxRowcount As Integer

rowCntr = 1
maxRowcount = 1

Do
Do
'Process your data here

'Step the row counter
rowCntr = rowCntr + 1

'Step the MainRow counter. This value
should be at
'99 when this first loop completes.
maxRowcount = maxRowcount + 1
Loop Until rowCntr = 99 Or maxRowcount = 500

'Move to the next batch and set the rowCntr
back to 1
'for the next batch
rowCntr = 1

Loop Until maxRowcount = 500

End Sub


Good Luck!
 
Back
Top