Hi Everyone,
I am writing a VBA macro but am having a type mismatch error. I pulled out the rest of my code, and cannot get this very simple code to run. Not understanding why a whole number cell value cannot be compared with another. I changed the variable type to "Long" and am still having the error.
Private Sub CommandButton1_Click()
Dim j As Integer
Dim k As Integer
j = Cells(26, 5).Value
k = Cells(27, 5).Value
If [j = k] Then
Cells(28, 5).Value = j
End If
End Sub
I am writing a VBA macro but am having a type mismatch error. I pulled out the rest of my code, and cannot get this very simple code to run. Not understanding why a whole number cell value cannot be compared with another. I changed the variable type to "Long" and am still having the error.
Private Sub CommandButton1_Click()
Dim j As Integer
Dim k As Integer
j = Cells(26, 5).Value
k = Cells(27, 5).Value
If [j = k] Then
Cells(28, 5).Value = j
End If
End Sub