VBA Formula with Quotations

EMcK01

Board Regular
Joined
Jun 14, 2015
Messages
125
Hi,

I'm sure this is a silly one but I can't figure it out. I'm wanting to add the following formula using my macro:
Code:
=IF(OR(C8>=6,D8>=6),"Strength","")

When I convert that into my script it looks like this:

Code:
Cells(r, 6).Formula = ("=IF(OR(" & Cells(r, 3).Address & ">=6," & Cells(r, 4).Address & ">=6)," & ""Strength"," & """" & ")")

However its giving me an issue around the word strength. I'm sure its associated with the quotation marks but these are required for the formula to work and I can't seem to re-work it generate the formula correctly.

Thanks,
EMcK
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
How about
Code:
Cells(r, 6).FormulaR1C1 = "=IF(OR(rc3>=6,rc4>=6),""Strength"","""")"
But you you are using a loop to insert the formula over a range of rows there is no need.
 
Upvote 0
Thanks for the reply, while that works I should of noted the row number is dynamic so the IF formula changes as it moves down the sheet.
 
Upvote 0
The row number is dynamic in that formula, but if you are putting the formula into every row via a loop you don't need to.
 
Upvote 0
Thanks for your reply again Fluff. I was trying to do so via a loop but this isn't working for me, what am doing wrong? Not every row requires formula so I can't do a copy down.
 
Upvote 0
Sorry Fluff, user error on my end when I thought it wasn't working. It was working perfectly well.
Thanks, EMcK
 
Upvote 0
You're welcome & thanks for the feedback.
If not every cell needs the formula, then you will probably need a loop.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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
Back
Top