I have the following code that deletes a lot of columns, copy and pastes one into column B and then sorts by column B.
Sub test()
Dim ws As Worksheet, lr As Long
Set ws = ActiveSheet
lr = ws.UsedRange.Rows.Count
With ws
.Range("C:D,K:O,R:V,X:AK,AM:AO").EntireColumn.Delete
.Range("B:B").Insert Shift:=xlToRight
.Range("J:J").Cut Destination:=.Range("B:B")
.Range("J:J").Delete
.Range("A" & lr).EntireRow.Delete
For x = lr To 2 Step -1
If Left(.Range("B" & x), 2) <> "29" Then .Range("A" & x).EntireRow.Delete
Next
End With
End Sub
I now need to include the previously deleted columns M & O and changed the code to show this....
.Range("C:D,K:L,R:V,X:AK,AM:AO").EntireColumn.Delete
.... and this also changed the column I needed to cut and paste to K....
.Range("B:B").Insert Shift:=xlToRight
.Range("K:K").Cut Destination:=.Range("B:B")
.Range("K:K").Delete
... but it isn't working. I do not understand the rest of the code as I didn't create it. The macro simply deletes all records !
Can anyone please help ?
Bookmarks