nerdalert22
New Member
- Joined
- Apr 19, 2019
- Messages
- 5
I can't seem to get the syntax right on my nested OR/ANDs section so I keep getting an error - please help! I'm sure there is a better way to do this than having all the InStr() OR InStr() but I'm not comfortable in VBA at all so I dont' know very much
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">'Loop search code
For i =2To LastRow
</code>
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">'Loop search code
For i =2To LastRow
</code>
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">'Check if columns do not match
If Alpha.Range("G"& i)<> Alpha.Range("H"& i)Then
'Pull out mismatches if contain specific strings
SelectCaseTrue
</code>
If Alpha.Range("G"& i)<> Alpha.Range("H"& i)Then
'Pull out mismatches if contain specific strings
SelectCaseTrue
</code>
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">'Search for specific strings
Case((InStr(1, Alpha.Range("H"& i),"E08.3")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.4")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.5")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.6")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.8")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.9")>0))Or _
(InStr(1, Alpha.Range("H"& i),"E09")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E10")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E11")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E13.0")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E13.1")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E13.2")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E13.3")>0))And _
((InStr(1, Alpha.Range("K"& i),"J0718")>0)Or _
(InStr(1, Alpha.Range("K"& i),"J2778")>0)Or _
(InStr(1, Alpha.Range("K"& i),"J9035")>0)Or _
(InStr(1, Alpha.Range("K"& i),"J7312")>0)Or _
(InStr(1, Alpha.Range("K"& i),"C9257")>0))
'look for UniqueID(colA) in TrackSheet to avoid duplicate copy
DuplicateCheck = Application.Match(Alpha.Range("A"& i).Value,_
TrackSheet.Columns(1),0)
If IsError(DuplicateCheck)Then
'If no match on UniqueID, copy values
TrackSheet.Cells(Rows.Count,1).End(xlUp)._
Offset(1,0).EntireRow.Value = Alpha.Rows(i).Value
EndIf
</code>
Case((InStr(1, Alpha.Range("H"& i),"E08.3")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.4")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.5")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.6")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.8")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E08.9")>0))Or _
(InStr(1, Alpha.Range("H"& i),"E09")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E10")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E11")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E13.0")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E13.1")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E13.2")>0)Or _
(InStr(1, Alpha.Range("H"& i),"E13.3")>0))And _
((InStr(1, Alpha.Range("K"& i),"J0718")>0)Or _
(InStr(1, Alpha.Range("K"& i),"J2778")>0)Or _
(InStr(1, Alpha.Range("K"& i),"J9035")>0)Or _
(InStr(1, Alpha.Range("K"& i),"J7312")>0)Or _
(InStr(1, Alpha.Range("K"& i),"C9257")>0))
'look for UniqueID(colA) in TrackSheet to avoid duplicate copy
DuplicateCheck = Application.Match(Alpha.Range("A"& i).Value,_
TrackSheet.Columns(1),0)
If IsError(DuplicateCheck)Then
'If no match on UniqueID, copy values
TrackSheet.Cells(Rows.Count,1).End(xlUp)._
Offset(1,0).EntireRow.Value = Alpha.Rows(i).Value
EndIf
</code>
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">EndSelect
EndIf
</code>
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Next i</code>EndIf
</code>