I'll show you what I have that works - and what I'm trying to do that doesn't.
This code works. It checks to see that ShortPostal Or ProtTerritory do not equal certain cells...it evaluates to False if they do not equal to the values in these cells. These are separated by an OR because if either of them doesn't meet the condition then I want to evaluate to false....
Now I want to check more than just these two variables....I want to check 3 more and I'm not sure how to do this....here's what I've got:![]()
ShortPostal = Mid(InSheet.Cells(theRow, 1).Value, 1, 6) ProtTerritory = InSheet.Cells(theRow, 4).Value Dim i As Integer Dim isGroup As Boolean isGroup = True For i = 1 To 9 If (Mid(InSheet.Cells(theRow + i, 1).Value, 1, 6) <> ShortPostal _ Or InSheet.Cells(theRow + i, 4).Value <> ProtTerritory) _ Then isGroup = False Exit For End If Next i
ShortPostal = Mid(InSheet.Cells(theRow, 1).Value, 1, 6)
ProtTerritory = InSheet.Cells(theRow, 4).Value
SemiTerritory = InSheet.Cells(theRow, 5).Value
UnProtTerritory = InSheet.Cells(theRow, 6).Value
SBUZone = InSheet.Cells(theRow, 7).Value
Dim i As Integer
Dim isGroup As Boolean
isGroup = True
For i = 1 To 9
If (Mid(InSheet.Cells(theRow + i, 1).Value, 1, 6) <> ShortPostal _
Or InSheet.Cells(theRow + i, 4).Value <> ProtTerritory) _
At this point, do I add the following?
Or InSheet.Cells(theRow + i, 4).Value <> ProtTerritory) _
Or InSheet.Cells(theRow + i, 5).Value <> SemiTerritory) _
Or InSheet.Cells(theRow + i, 6).Value <> UnProtTerritory) _
Or InSheet.Cells(theRow + i, 7).Value <> SBUZone) _
Then
isGroup = False
Exit For
End If
Next i
When I try to do the above it doesn't work - is there a smarter way to go about this? I'm very new to VBA so I'm convinced I'm missing something obvious - any help would be apprecated!
Thanks!
-Tara
Bookmarks