Run Macro on all worksheet except 2

jbesclapez

Active Member
Joined
Feb 6, 2010
Messages
275
Hello Mr Excel,

I hope you are fine.
I am not but will be soon as i am pretty sure you can help me. :)
I am trying to run a macro on excel 2010 on a XLS file. (old version excel).
The macro should work but i can not find why it is not working.

This macro works : (I only exclude one worksheet called Document Map)

Code:
Sub Loop2Working()
    Dim sht2 As Worksheet
 
ActiveWorkbook.Worksheets
    For Each sht2 In Worksheets
        If sht2.Name <> "Document map" Then
 
        sht2.Activate
        Call DeleteRow
        
        Else
        Range("A1:B1").Select
        End If
    Next sht2

End Sub

But this macro where i add a line with an OR is not working...

Code:
Sub Loop2Working()
    Dim sht2 As Worksheet
 
ActiveWorkbook.Worksheets
    For Each sht2 In Worksheets
        If sht2.Name <> "Document map" [COLOR=Red]OR _[/COLOR]
If sht2name <> "Projects-Interv" Then
 
        sht2.Activate
        Call DeleteRow
        
        Else
        Range("A1:B1").Select
        End If
    Next sht2

End Sub

Please note that the worksheet Projects-Interv is not in the workbook yet.


Here is the other macro it is calling (if you need it)
Code:
Sub DeleteRow()

    Range("E6:E1000").SpecialCells(xlCellTypeBlanks).Select
    Selection.EntireRow.Delete
    Range("A1").Select 'Get back to top of Sheet
End Sub


Thanks for your usual help. Always appreciated.:beerchug:
 

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.

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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