VBA Multiplication Problem

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,002
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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.

Thanks in advance Stephen.

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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,304
Office Version
  1. 365
Platform
  1. Windows
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?
 

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,002
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,304
Office Version
  1. 365
Platform
  1. Windows
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?
 

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,002
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,029
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.
 

Forum statistics

Threads
1,141,679
Messages
5,707,786
Members
421,527
Latest member
Tamiwsw

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Top