Announcement

Collapse
No announcement yet.

I need to shift columns down by specific value

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • I need to shift columns down by specific value



    Hello,

    I am new use of VBA, therefore I am not sure how to manipulate with the shift of columns.
    For example, I need to shift columns down by specific rows value which is declared at column A:

    0 103.5182 104.7105 103.9517 103.9517 105.7945 103.5182
    3 103.9517 104.9273 105.4693 104.1685 101.2418 103.9517
    5 102.5426 104.7105 105.0357 105.3609 104.2769 102.5426
    9 104.9273 105.4693 104.2769 106.2281 105.7945 104.9273 104.7105
    15 105.9029 107.2036 104.1685 104.3853 106.9868 105.9029 104.9273
    104.3853 106.4449 104.8189 104.7105 104.8189 104.3853 104.7105 103.9517
    103.4098 103.5182 103.4098 102.3258 104.3853 103.4098 105.4693 105.4693
    102.9762 104.7105 103.5182 102.9762 103.6266 102.9762 107.2036 105.0357
    103.4098 103.735 105.2525 102.9762 104.3853 103.4098 106.4449 104.2769
    104.0601 103.4098 104.8189 105.1441 106.0113 104.0601 103.5182 104.1685 103.9517
    103.735 103.6266 103.735 105.7945 106.2281 103.735 104.7105 104.8189 104.1685
    102.7594 104.1685 103.735 103.3014 105.9029 102.7594 103.735 103.4098 105.3609
    104.2769 103.193 104.2769 104.9273 105.7945 104.2769 103.4098 103.5182 106.2281
    102.5426 103.3014 104.6021 104.7105 106.77 102.5426 103.6266 105.2525 104.3853
    103.8433 106.2281 102.5426 103.6266 105.6861 103.8433 104.1685 104.8189 104.7105
    104.0601 106.77 105.5777 102.8678 102.651 104.0601 103.193 103.735 102.3258 105.7945
    103.3014 103.735 102.9762 101.2418
    106.2281 104.2769 102.9762 104.2769
    106.77 104.6021 105.1441 105.7945
    102.5426 105.7945 106.9868
    105.5777 103.3014 104.8189
    104.9273 104.3853
    104.7105 103.6266
    103.6266 104.3853
    102.8678 106.0113
    106.2281
    105.9029
    105.7945
    106.77
    105.6861
    102.651
    The origin data is provided on the left. Whereas shifted date by specific rows value. This is posed on the right.

  • #2
    Try this.
    Code:
    Sub x()
    
    Dim r As Long
    
    For r = 1 To Range("A" & Rows.Count).End(xlUp).Row
        If Cells(r, 1) > 0 Then
            Range("A1").Offset(, r).Resize(Cells(r, 1)).Insert shift:=xlDown
        End If
    Next r
    
    End Sub

    Comment


    • #3


      Thank you! That works great.

      Comment

      Working...
      X