If Then IF issue?

chris-uk-lad

Registered User.
Local time
Today, 14:58
Joined
Jul 8, 2008
Messages
271
Sorry if this is general knowledge, i cant find a suitable answer for me.

I need an if statement with 2 clauses before moving on, like this

Code:
If searching_ws.Name <> "STAT" Or searching_ws.Name <> "BASIC" Then

but know this to be incorrect syntax, i believe it would work with a

Code:
If searching_ws.Name <> "STAT" Then
If searching_ws.Name <> "BASIC" Then

but imo would be bad practice.

Any tips? Thanks
 
If searching_ws.Name <> "STAT" And searching_ws.Name <> "BASIC" Then

Would be correct...
 
If searching_ws.Name <> "STAT" And searching_ws.Name <> "BASIC" Then

Would be correct...

im aware of the and statement but it wont work in my case, i basically have:

Code:
If searching_ws.Name <> "STAT" Or searching_ws.Name <> "BASIC" Then
      maps_ws.Cells(maps_ws_row, 5).Value = searching_ws.Name
      maps_ws.Cells(maps_ws_row, 6).Value = searching_ws.Cells(foundCell.Row, 1).Value
      GoTo Get_References_FOUND_IT
Else
 
If searching_ws.Name = "STAT" Then
       maps_ws.Cells(maps_ws_row, 5).Value = searching_ws.Name
       maps_ws.Cells(maps_ws_row, 6).Value = searching_ws.Cells(foundCell.Row, 1).Value '
       maps_ws.Cells(maps_ws_row, 6).Value = Sheets("STAT").Range("C16").Value
       GoTo Get_References_FOUND_IT
Else
If searching_ws.Name = "BASIC" Then
       maps_ws.Cells(maps_ws_row, 5).Value = searching_ws.Name
       maps_ws.Cells(maps_ws_row, 6).Value = searching_ws.Cells(foundCell.Row, 1).Value '
       maps_ws.Cells(maps_ws_row, 6).Value = Sheets("BASIC").Range("B36").Value
       GoTo Get_References_FOUND_IT
End If

Im searching through about 10 worksheets, and dont wish an individual statement for each sheet (via a case or large nested IF)
 
Code:
If searching_ws.Name = "STAT" Then
ElseIf searching_ws.Name = "BASIC" Then
Else
    ' anything that is not equal to "STAT" and "BASIC"
End If

Sorry for the slight re-write, but this way is best, if you need to add sheets to do things differently you dont need to add it twice... just once.
 

Users who are viewing this thread

Back
Top Bottom