Help with a macro please

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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
 
Upvote 0
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!
 
Upvote 0
You're welcome & thanks for the feedback.

The macro recorder always works on the ActiveSheet & will not give you sheet names
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

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