Help to check sheet name then do something

sbv1986

Board Regular
Joined
Nov 2, 2017
Messages
87
Hi all I have code below work well but I want to change this line:
<code style="box-sizing: border-box; font-family: inherit; font-size: 1em;">If Sh.Name <> "LocKH" And Sh.Name <> "Ma" Then
to

<code style="box-sizing: border-box; font-family: inherit; font-size: 1em;">If Sh.Name = array(A,B,C,D,E,F) Then

Please help me, thanks./.</code></code></pre>
Code:
[COLOR=#141414][FONT=inherit]Option Explicit[/FONT][/COLOR]<code style="box-sizing: border-box; font-family: inherit; font-size: 1em;">
Sub filter()
    Application.ScreenUpdating = False
    Dim a, b(1 To 65000, 1 To 15), lR, Sh As Worksheet, endR As Long, i As Long, j As Long, k As Long
    Dim ii As Long, Data As Variant

    Sheets("LocKH").Range("b5:q5000").ClearContents
    endR = Sheets("Ma").Range("B" & Rows.Count).End(3).Row + 1
    
    If endR < 4 Then Exit Sub
    Data = Sheets("Ma").Range("B3:B" & endR).Value    '
    endR = UBound(Data) - 1
    For Each Sh In ThisWorkbook.Worksheets
       [COLOR=#ff0000] If Sh.Name <> "LocKH" And Sh.Name <> "Ma" Then [/COLOR]   '
            'do something
        End If
    Next
    Application.ScreenUpdating = True </code>[COLOR=#141414][FONT=inherit]End Sub[/FONT][/COLOR]
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi all I have code below work well but I want to change this line:
<code style="box-sizing: border-box; font-family: inherit; font-size: 1em;">If Sh.Name <> "LocKH" And Sh.Name <> "Ma" Then
to

<code style="box-sizing: border-box; font-family: inherit; font-size: 1em;">If Sh.Name = array(A,B,C,D,E,F) Then

Please help me, thanks./.</code></code>
Code:
if not iserror(application.match(Sh.name,split("A,B,C,D,E,F",","),0))
 
Last edited:
Upvote 0
What about this:

Code:
shArr = Array("Sheet1", "Sheet5")

For i = LBound(shArr) To UBound(shArr)
    Set sh = Sheets(shArr(i))
    MsgBox sh.Name
Next
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,161
Members
448,948
Latest member
spamiki

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