VBA not working

RattlingCarp3048

Board Regular
Joined
Jan 12, 2022
Messages
202
Office Version
  1. 365
Platform
  1. Windows
i have a case number in column B where i need to filter to all line items containing " ARM" (space ARM) and delete those rows then unfilter. below is the line of code i have used many times in other worksheets without issues. when i manually filter it works as expected. however, when i test in VBA it filters to nothing. no data is shown and none has been deleted. when i try to record the macro i get an error message saying there are too many line continuations. Can someone help figure out what i am doing wrong?

ActiveSheet.Range("$A:$AA").AutoFilter Field:=2, Criteria1:=" ARM"
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A:$AA").AutoFilter Field:=2
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Replace the Delete line with:
VBA Code:
ActiveSheet.Range("A1").CurrentRegion.Offset(1).SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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
Back
Top