For some reason my if statement does not obey the And clause in the following code:
Sub Method2()
Dim i, j, k As Integer
Dim fluidIDs As Variant
Dim fID As Integer
Dim fType As String
i = 2
j = 2
fluidIDs = Array(207 ... omitted for convenience)
Do While i < 4062
Workbooks("WorkBook1.xlsm").Sheets("WorkSheet1").Activate
fID = Cells(i, 3)
fType = Cells(i, 4)
For k = 0 To 65
If ((fType <> "InputSelection" Or fType <> "MealBar" Or fType <> "CurrentMeal") And fluidIDs(k) + 100 = fID) Then
Range("A" & i & ":E" & i).Select
Selection.Copy
Workbooks("WorkBook1.xlsm").Sheets("WorkSheet2").Activate
ActiveSheet.Cells(j, 30).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
j = j + 1
Exit For
End If
Next k
i = i + 1
Loop
'
End Sub
But "if" obeys the And clause in this code
Sub Method1()
Dim i, j, k As Integer
Dim fluidIDs As Variant
Dim fID As Integer
Dim fType As String
i = 2
j = 200
fluidIDs = Array(207 ...)
Do While i < 5382
Workbooks("WorkBook1.xlsm").Sheets("WorkSheet1").Activate
fID = Cells(i, 3)
fType = Cells(i, 4)
For k = 0 To 65
If (fluidIDs(k) + 100) = fID And (fType Like "InputSelection" Or fType Like "MealBar" Or fType Like "CurrentMeal") Then
Range("A" & i & ":E" & i).Select
Selection.Copy
Workbooks("WorkBook1.xlsm").Sheets("WorkSheet2").Activate
ActiveSheet.Cells(j, 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
j = j + 1
Exit For
End If
Next k
i = i + 1
Loop
'
End Sub
I want to fix the if statement in the first code in order to get what I need. Any suggestions?
Sub Method2()
Dim i, j, k As Integer
Dim fluidIDs As Variant
Dim fID As Integer
Dim fType As String
i = 2
j = 2
fluidIDs = Array(207 ... omitted for convenience)
Do While i < 4062
Workbooks("WorkBook1.xlsm").Sheets("WorkSheet1").Activate
fID = Cells(i, 3)
fType = Cells(i, 4)
For k = 0 To 65
If ((fType <> "InputSelection" Or fType <> "MealBar" Or fType <> "CurrentMeal") And fluidIDs(k) + 100 = fID) Then
Range("A" & i & ":E" & i).Select
Selection.Copy
Workbooks("WorkBook1.xlsm").Sheets("WorkSheet2").Activate
ActiveSheet.Cells(j, 30).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
j = j + 1
Exit For
End If
Next k
i = i + 1
Loop
'
End Sub
But "if" obeys the And clause in this code
Sub Method1()
Dim i, j, k As Integer
Dim fluidIDs As Variant
Dim fID As Integer
Dim fType As String
i = 2
j = 200
fluidIDs = Array(207 ...)
Do While i < 5382
Workbooks("WorkBook1.xlsm").Sheets("WorkSheet1").Activate
fID = Cells(i, 3)
fType = Cells(i, 4)
For k = 0 To 65
If (fluidIDs(k) + 100) = fID And (fType Like "InputSelection" Or fType Like "MealBar" Or fType Like "CurrentMeal") Then
Range("A" & i & ":E" & i).Select
Selection.Copy
Workbooks("WorkBook1.xlsm").Sheets("WorkSheet2").Activate
ActiveSheet.Cells(j, 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
j = j + 1
Exit For
End If
Next k
i = i + 1
Loop
'
End Sub
I want to fix the if statement in the first code in order to get what I need. Any suggestions?