Help with a macro please

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
149
Good Afternoon Folks,

I need help with the attached macro please. I need it to run on the specified sheet (POS IMPORT). Right now it is running on whichever sheet
is open in the workbook. I have messed with it for 2 hours but not able to get it correct.

Any help would be appreciated!

Thank you!!

Code:
Sub DeletePLURows()    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Application.ScreenUpdating = True
    Range("A1:A" & LastRow).AutoFilter Field:=1, Criteria1:="<>0064914800*"
    Range("A2:A" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    Range("A1").AutoFilter
    Application.ScreenUpdating = True
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,297
Office Version
  1. 365
Platform
  1. Windows
How about
Code:
Sub Buns1976()
   Dim LastRow As Long
   
   Application.ScreenUpdating = False
   With Sheets("POS IMPORT")
      LastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
      .Range("A1:A" & LastRow).AutoFilter Field:=1, Criteria1:="<>0064914800*"
      .Range("A2:A" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
      .Range("A1").AutoFilter
   End With
End Sub
 

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
149
Works like a champ Fluff! I'm trying to learn this stuff with a limited amount of time to do so but struggle with some of it. For some reason
the Record Macro is not picking up the sheet specific stuff and I don't know if it should or not?

Thanks so much. You are the best!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,297
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.

The macro recorder always works on the ActiveSheet & will not give you sheet names
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,282
Messages
5,836,401
Members
430,425
Latest member
xlsee

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