Simple VBA Amendment

MrMaker

Board Regular
Joined
Jun 7, 2018
Messages
56
Office Version
  1. 365
Platform
  1. Windows
Hello all,

A really simple one for you folk I'm sure.

I've got some existing code which I need to adapt ever so slightly.

1) The code currently runs on all sheets except 'Summary', but I need it to run on all sheets except 'Summary' and 'FAQs'

2) The other tabs have an autofilter on row 4 (which is the basis of the code), but I'm not sure this code is picking up that the code isn't on the top row, do I need to change something to reflect that.

Private Sub Workbook_Open()
Dim Sht As Worksheet, R As Range
Application.ScreenUpdating = False
For Each Sht In Me.Worksheets
If Sht.Name <> "Summary" Then
Set R = Sht.Range("A1").CurrentRegion
R.AutoFilter field:=1, Criteria1:="<>" & Sheets("Summary").Range("A1")
On Error Resume Next
Set R = R.Offset(1, 0).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
Sht.AutoFilterMode = False
If Not R Is Nothing Then R.EntireRow.Delete
End If
Sht.Rows.RowHeight = 25
Next Sht
With Sheets("Summary")
.Range("A1").Value = .Range("A1").Value
.Rows.RowHeight = 20
End With
Application.ScreenUpdating = True
End Sub

Thank you in advance

MrMaker
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
How about
VBA Code:
   If Sht.Name <> "Summary" And Sht.Name <> "FAQs" Then
Also when posting code please post as text with the code tags, not as a table. Thanks
 
Upvote 0
Thank you, and sorry!

Any idea on having the autofilter on row 4?
 
Upvote 0
How about
VBA Code:
   For Each Sht In Me.Worksheets
      If Sht.Name <> "Summary" And Sht.Name <> "FAQs" Then
         Sht.Range("A4").AutoFilter 1, "<>" & Sheets("Summary").Range("A1")
         Sht.AutoFilter.Range.Offset(1).EntireRow.Delete
         Sht.AutoFilterMode = False
      End If
      Sht.Rows.RowHeight = 25
   Next Sht
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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