PDA

View Full Version : [SOLVED] Moving Data around in a Row.



tubularowl
07-12-2016, 05:21 AM
Hi,

I have put together (successfully) quite a complicated Macro sequence which works well but now I have a problem that I can't solve.

I want to create a small code loop that Looks down 500 rows. If the value of the row in column AL is not equal to a specific value then I want to be able to delete cell AL in that row and then move all the data from row AM onwards one cell to the left.

If anyone knows how it is possible to do this that would be great. You may possibly know another way of doing it.

mdmackillop
07-12-2016, 05:33 AM
If I understand correctly

Sub Test02()
For i = 1 To 500
If Cells(i, "AL") <> 5 Then Cells(i, "AL").Delete shift:=xlToLeft
Next
End Sub
'or
Sub Test03()
With Columns("AL:AL")
.AutoFilter Field:=1, Criteria1:="<>5"
.SpecialCells(2).Delete Shift:=xlToLeft
End With
End Sub

tubularowl
07-12-2016, 06:15 AM
If i understand correctly

Sub Test02()
For i = 1 To 500
If Cells(i, "AL") <> 5 Then Cells(i, "AL").Delete shift:=xlToLeft
Next
End Sub
'or
Sub Test03()
With Columns("AL:AL")
.AutoFilter Field:=1, Criteria1:="<>5"
.SpecialCells(2).Delete Shift:=xlToLeft
End With
End Sub




That's perfect !!


:yes

The first one worked perfectly. I have been messing around all morning to sort this out and now it's working exactly how I wanted.

Thank You so much.

Ray