seriouslystuck
Board Regular
- Joined
- Sep 24, 2009
- Messages
- 97
Hi All
I could really do with some help. Im trying to write a macro that searches a column and deletes rows depending on what value is in a cell. EG in column J I have 15k rows of aplha numeric codes, for example y20, 966, u22, y19.. I want to find the 966 and y20 and delete the rows but keep the u22 and y19.
I have got the code below but i dont know how to add another 'if not'. I do very little vba so excuse the novice approach.
Range("A1").Select
End Sub
Any help would be great
TIA
I could really do with some help. Im trying to write a macro that searches a column and deletes rows depending on what value is in a cell. EG in column J I have 15k rows of aplha numeric codes, for example y20, 966, u22, y19.. I want to find the 966 and y20 and delete the rows but keep the u22 and y19.
I have got the code below but i dont know how to add another 'if not'. I do very little vba so excuse the novice approach.
Private Sub CommandButton1_Click()
Range("J1").Select
Do Until Selection.Value = ""
If Not Selection.Value = "y19" Then
Selection.EntireRow.Delete
Range("J1").Select
Do Until Selection.Value = ""
If Not Selection.Value = "y19" Then
Selection.EntireRow.Delete
Else
Selection.Offset(1, 0).Select
End If
Loop
Selection.Offset(1, 0).Select
End If
Loop
Range("A1").Select
End Sub
Any help would be great
TIA