This is the code that tries to modify the background color of some cells depending on the condition. It worked in a friend's computer where i created the code but when I sent it to my computer and run it, the message type missmatch appeared.
Debuger stops at the assignation Cells(i,j).Interior.Color = RGB(0,255,0)
Maybe is it a compatibility stuff with excel version???
Sub Acumuladores()
Dim j As Integer
Dim i As Integer
Dim Title As String
Dim numColumnas As Integer
numColumnas = 36
j = 1
Do While j < numColumnas
Title = Cells(1, j)
i = 1
Do While Cells(i, 1) <> ""
i = i + 1
If (i Mod 2 = 0) Then
If (Title = "PV" Or Title = "PPALUNITCCY1" Or Title = "PPALUNITCCY1" Or Title = "IMPORTE_TOTAL_ACUMULADO" Or Title = "FXFORWARDPPAL" Or Title = "FXFORWARDRATE" Or Title = "FXFWDVTO") Then
If Cells(i, j) = -Cells(i + 1, j) Then
Cells(i, j).Interior.Color = RGB(0, 255, 0)
Else
Cells(i, j).Interior.Color = RGB(255, 0, 0)
End If
End If
If (Title = "TIPOEMISION" Or Title = "STARTDATE" Or Title = "MATURITYDATE" Or Title = "DESCRIPTION" Or Title = "CECACUMTIPO" Or Title = "CECACUMRATIO" Or Title = "CECACUMRATIO1" Or Title = "CECACUMNOBS" Or Title = "CECACUMFREQ" Or Title = "CECACUMSTRIKE" Or Title = "CECACUMBARRERA") Then
If Cells(i, j) = Cells(i + 1, j) Then
Cells(i, j).Interior.Color = RGB(0, 255, 0)
Else
Cells(i, j).Interior.Color = RGB(255, 0, 0)
End If
End If
End If
Loop
j = j + 1
Loop
End Sub
Inside the if statement:
If Cells(i, j) = -Cells(i + 1, j) Then
Cells(i, j).Interior.Color = RGB(0, 255, 0)
Else
You have -Cells
instead of Cells
. So fix it using:
If Cells(i, j) = Cells(i + 1, j).Value * -1Then
Cells(i, j).Interior.Color = RGB(0, 255, 0)
Else