MACRO FORMULA HELP

rikvny02

Board Regular
Joined
Aug 9, 2022
Messages
95
Office Version
  1. 365
Platform
  1. Windows
Can someone help me to understand why entering a formula this way does not work

Range("K5").Select
ActiveCell.Formula2R1C1 = "=IF(LIST!B2="",1,LIST!B2)"

but, entering this way does.

Range("T5").Select
ActiveCell.FormulaR1C1 = "=IF(list!R[6]C[-18]="""",10,list!R[6]C[-18])"
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
If you are entering the exact range in non-R1C1 format (like your first one), get rid of the "R1C1" part.
You also need to double-up the double-quotes part.
You can also combine the two rows to just this:
VBA Code:
Range("K5").Formula = "=IF(LIST!B2="""",1,LIST!B2)"
 
Upvote 1
Solution
You need to double the quotes, one set is what appears in the cell, the other tells VBA that it is text
VBA Code:
Range("K5").Formula2 = "=IF(LIST!B2="""",1,LIST!B2)"

Edit: oops Joe beat me to it and mentioned the R1C1
 
Upvote 0
If you are entering the exact range in non-R1C1 format (like your first one), get rid of the "R1C1" part.
You also need to double-up the double-quotes part.
You can also combine the two rows to just this:
VBA Code:
Range("K5").Formula = "=IF(LIST!B2="""",1,LIST!B2)"
THANK YOU.
 
Upvote 0
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,223,914
Messages
6,175,351
Members
452,638
Latest member
Oluwabukunmi

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