Numbered rows

Milade8080

New member
Joined
Mar 13, 2014
Messages
19
Reaction score
0
Points
0
Hello
How do I do the following operations?
Page 1 ---> A1=1,A2=2,.....A40=40 D1=41,D2=42,.....D40=80
Page 2 ---> A41=81,A2=82,.....A80=120 D41=121,D42=122,.....D80=160
...... ................................. ................................
Continues until the desired number (For example 4000)
 
a small macro will do the trick:
Code:
Sub blah()
StopValue = 4000  'adjust yourself.
For i = 1 To StopValue Step 80
  myrow = ((i - 1) / 2) + 1
  If i <= StopValue Then
    ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(myrow + 40, 1)
    With Cells(myrow, "A")
      .Value = i
      .DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, Step:=1, Stop:=Application.Min(i + 40 - 1, StopValue), Trend:=False
      If i + 40 <= StopValue Then
        With .Offset(, 3)
          .Value = i + 40
          .DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, Step:=1, Stop:=Application.Min(i + 80 - 1, StopValue), Trend:=False
        End With
      End If
    End With
  End If
Next i
End Sub
 
Back
Top