deleting rows of data

Status
Not open for further replies.

divapaxo

Board Regular
Joined
Feb 4, 2005
Messages
110
hi all

could someone please advise how you would write
to keep data in column "A" that starts with "HL"

here is the code i have written but the last part is incorrect and i don't know what to put

please help

Sub deleterows()

Dim j, lastrow As Long
Dim dest As Long
Dim x As Range
Worksheets("hostbalme").Activate

lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For j = lastrow To 1 Step -1

Set x = Cells(j, "A")
x.Select



If (x.Value, 2) = "HL" Then x.EntireRow.Delete



Next j
End

End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

roaze2000

New Member
Joined
Jul 19, 2005
Messages
49
Did you try the Autofilter?
You can record your macro, and slect the value you want to delete, delete the rows and desactivate the autofilter and then stop your macro, to see what VBA it used.

THan you just clean that up and your done.
 
Status
Not open for further replies.

Forum statistics

Threads
1,141,098
Messages
5,704,319
Members
421,338
Latest member
Pepess

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top