# VBA Multiplication Problem

#### Stephen_IV

##### Well-known Member
I want to thank everyone for all the help in the past. I am trying to get this to work but am having a problem this is the problem area If cells(i,2)*cells(i,9). Could someone please straighten me out.

Sub doesitequal()
Dim i as Long
For i = 1 to 100
If cells(i,2)*cells(i,9)<>cells(i,10) then cells(i,13).interior.colorindex = 3
Next i
End Sub

### Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Stephen

What's the actual problem?

Does this work?
Code:
``````Sub doesitequal()
Dim i as Long
For i = 1 to 100
If cells(i,2).Value*cells(i,9).Value<>cells(i,10).Value then cells(i,13).interior.colorindex = 3
Next i
End Sub``````
By the way could you not just use conditional formatting?

I keep getting a Run time error'13':
Type mismatch
I could use conditional formatting but you cannot count conditional formatting so I need to use code.

Stephen

What do you mean you can't count conditional formatting?

All you need to do is use the condition with a sumif/countif/sumproduct etc formula.

Did you try the code I posted?

Norie,

Thanks for getting back to me. What I meant is to count the actual color not the condition. Even with your code I am still getting a Run time error'13':
Type mismatch

I keep getting a Run time error'13':
Type mismatch
I could use conditional formatting but you cannot count conditional formatting so I need to use code.
The type mismatch is probably because you don't have numbers in some of the cells.

And, I don't see anything in your code that cannot be done with C.F.

Replies
8
Views
136
Replies
1
Views
139
Replies
6
Views
206
Replies
1
Views
254
Replies
3
Views
392

1,219,960
Messages
6,151,163
Members
451,012
Latest member
OH650R

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back