Help with a macro please

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
138
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
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,384
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
138
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
53,384
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,493
Messages
5,601,998
Members
414,490
Latest member
Rip181

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