if statement & in list

L

Legacy 15162

Guest
is ther some type of way to say in vba,
if xlws.name not in("blah","blah-blah","blah-blah-blah") then
do this
end if
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Everything is pratically possible in VBA but you will need to be more precise in what you want to do. If you could post a concrete example it will help..

See ya
 
Upvote 0
While xlWB.Worksheets.Count < rsStoreID.RecordCount
xlWB.Worksheets.Add
Wend

' For loop used to work with worksheets one at a time

For i = 1 To xlWB.Worksheets.Count
' Sequel String to pull back selected fields
Set xlWS = xlWB.Worksheets(i)
if xlws.Name not = ("CONTROL","APC","LA-TX","Cen LA","West Laf","South LA","Midland","Odessa","Carolinas","C Charlotte","E Charlotte","N Charlotte","SW Charlotte","W Charlotte","S Charlotte") then

stSql = "Select [dbo_FTPlan].*" & _
" From [dbo_FTPlan]" & _
" Where [dbo_FTPlan].[StoreNo] = " & Right(xlWS.Name, 5)

Set rsStoreData = CurrentDb.OpenRecordset(stSql)
PopFTMatrix xlWS, rsStoreData

rsStoreID.MoveNext
End If

Next i
 
Upvote 0
Take a look at the Select Case structure.

Perhaps something like this.
Code:
For Each xlws In xlWB.Worksheets

    Select Case xlws.Name
    
        Case "CONTROL", "APC", "LA-TX", "Cen LA", "West Laf", "South LA", "Midland", "Odessa", "Carolinas", "C Charlotte", "E Charlotte", "N Charlotte", "SW Charlotte", "W Charlotte", "S Charlotte"
            ' do nothing
        Case Else
            
            stSql = "Select [dbo_FTPlan].*" & _
                    " From [dbo_FTPlan]" & _
                    " Where [dbo_FTPlan].[StoreNo] = " & Right(xlws.Name, 5)
        
                    Set rsStoreData = CurrentDb.OpenRecordset(stSql)
                    PopFTMatrix xlws, rsStoreData
        
                    rsStoreID.MoveNext
    End Select

Next xlws
 
Upvote 0

Forum statistics

Threads
1,221,889
Messages
6,162,624
Members
451,778
Latest member
ragananthony7911

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