I am trying to compare 2 string values at the same time - Account # and Account Name. I've explicitly set all variables as Strings, however I am still getting a mismatch error in my IF comparison.
Does anyone know what is it I'm doing wrong?
Dim i As Integer
For i = 2 To 10
Dim accountNumber As String
accountNumber = CStr(Sheet1.Cells(i, 2).Value)
Dim accountName As String
accountName = CStr(Sheet1.Cells(i, 3).Value)
Dim c As Integer
c = 4
Dim j As Integer
For j = 2 To 14831
Dim accountNumber2 As String
accountNumber2 = CStr(Sheet2.Cells(j, 2).Value)
Dim accountName2 As String
accountName2 = CStr(Sheet2.Cells(j, 3).Value)
If (accountNumber = accountNumber2 & accountName = accountName2) Then
Dim platform As String
platform = Sheet2.Cells(j, 11).Value
Sheet1.Cells(i, c).Value = platform
c = c + 1
End If
Next j
Next i
End Sub
&is notandin VBA. Try:If accountNumber = accountNumber2 and accountName = accountName2 Then