Results 1 to 2 of 2

Thread: Numbered rows

  1. #1

    Question Numbered rows



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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)

  2. #2
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,844
    Articles
    0
    Excel Version
    365
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •