Consulting

Results 1 to 2 of 2

Thread: Solved: Shifting rows to the right.

  1. #1
    VBAX Regular
    Joined
    Feb 2009
    Posts
    22
    Location

    Solved: Shifting rows to the right.

    Hi experts,

    I want to shift the first 11 rows in my spreadsheet 16 columns to the right, the next 11 rows 15 columns to the right, the next 11 rows 14 across, etc etc

    This will happen for the first 176 rows (i.e. until the last block of 11 is moved only 1 to the right)

    If anyone can supply code to do this it would be really appreciated.

    Thanks in advance

    Chris

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    [vba]

    Dim i As Long
    Dim LastRow As Long
    Dim ShiftRows As Long

    With ActiveSheet

    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    ShiftRows = 16
    For i = 1 To LastRow Step 11

    .Cells(i, "A").Resize(11, ShiftRows).Insert Shift:=xlToRight
    ShiftRows = ShiftRows - 1
    If ShiftRows < 1 Then ShiftRows = 1
    Next i
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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