aellington287
New Member
- Joined
- Mar 7, 2016
- Messages
- 7
I have programmed some conditional formatting using VBA, comparing the values of 2 cells in many iterations. The issue is that some of my coworkers do not understand that in order for these numbers to be compared, they must have the same format. Some of them have put words in one of the cells and then....you guessed it, they got a mismatch error which gives them the option to debug the program. What line of code can I use to skip an iteration if the cells are mismatched? Here is an example from my code:
For i = 5 To 49
For j = 15 To 26
If Cells(i, 30) = "greater than or equal" Then
***
If Cells(i, j) >= Cells(i, 12) - (Cells(i, 12) * 0.1) And Cells(i, j) < Cells(i, 12) Then Cells(i, j).Interior.Color = RGB(250, 225, 50)
If Cells(i, j) >= Cells(i, 12) Then Cells(i, j).Interior.Color = RGB(100, 250, 100)
If Cells(i, j) < Cells(i, 12) - (Cells(i, 12) * 0.1) Then Cells(i, j).Interior.Color = RGB(250, 100, 100)
If Cells(i, j) = "" Then Cells(i, j).Interior.ColorIndex = 0
This line of code would need to be entered where I have placed the three asterisks. Any help would be appreciated.
For i = 5 To 49
For j = 15 To 26
If Cells(i, 30) = "greater than or equal" Then
***
If Cells(i, j) >= Cells(i, 12) - (Cells(i, 12) * 0.1) And Cells(i, j) < Cells(i, 12) Then Cells(i, j).Interior.Color = RGB(250, 225, 50)
If Cells(i, j) >= Cells(i, 12) Then Cells(i, j).Interior.Color = RGB(100, 250, 100)
If Cells(i, j) < Cells(i, 12) - (Cells(i, 12) * 0.1) Then Cells(i, j).Interior.Color = RGB(250, 100, 100)
If Cells(i, j) = "" Then Cells(i, j).Interior.ColorIndex = 0
This line of code would need to be entered where I have placed the three asterisks. Any help would be appreciated.