I have a simple code but cant get it to loop thru the rest of the worksheet. Its suppose to see the value in K then shift the everything to the right that amount and only from that point.
Sorry i left out that it has to continue to 52. So the code will be super long. Looking for a way to make it simple.
Sub Findandcut()
Dim row As Long
Dim i As Integer
For row = 4 To 10000
If Range("K" & row).Value Like "2" Then
For i = 1 To 1
Range("K" & row).Insert Shift:=xlToRight
Next
End If
If Range("K" & row).Value Like "3" Then
For i = 1 To 2
Range("K" & row).Insert Shift:=xlToRight
Next
End If
If Range("K" & row).Value Like "4" Then
For i = 1 To 3
Range("K" & row).Insert Shift:=xlToRight
Next
End If
CodePudding user response:
To go out to 52..
Sub Findandcut()
Dim row As Long, i As Long, x As Long
For row = 4 To 10000
x = Range("K" & row).Value
If x > 1 And x < 53 Then
For i = 1 To x - 1
Range("K" & row).Insert Shift:=xlToRight
Next
End If
Next
End Sub