I'm trying to concatenate de values of 2 cells in each raw, along 2 columns.
If the concatenated value (Temp) is equal to another one (MaxT) some cells to the right are affected by a change of background colour. All values are strings of text.
MaxT = CStr(MaxT)
For i = 5 To 88
TempT = Sheets("B").Range(Cells(i, 2)).Value & Sheets("B").Range(Cells(i, 5)).Value
If TempT = MaxT Then
Range(Cells(i, 7), Cells(i, 36)).Interior.ColorIndex = 15
End If
Next i
我收到了这个错误:
运行时错误1004
应用程序定义或对象定义的错误
代码中的问题在哪里?
答案 0 :(得分:1)
以下是解决方案:
MaxT = CStr(MaxT)
For i = 5 To 88
TempT = Sheets("B").Cells(i, 2).Value & Sheets("B").Cells(i, 5).Value
If TempT = MaxT Then
Range(Cells(i, 7), Cells(i, 36)).Interior.ColorIndex = 15
End If
Next i