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 formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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