IF formula is used in Macro, Get If ranges value from Cell.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Using Excel 2010
Hello,

The following formula I am using in Macro which work fine, I want help does it is possible in to formula IF where is C6 get value row 6 from cell S2 & C14 get value row 14 from cell S3

VBA Code:
Range("S6:AF50).Formula = "=IF(C6=C14,""A"",""B"")"

Regards,
Moti
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try this:
Excel Formula:
Range("S6:AF50").Formula = "=IF(C" & Range("S2") & "=C" & Range("S3") & ",""A"",""B"")"
 
Upvote 1
Solution
You are welcome!

The key to remember is that you are combining literal string values and values from ranges (or variables).
You enclose literal text pieces in double-quotes, and range references and variables must NOT be enclosed in double quotes, and they are all combined with "&".
 
Upvote 1

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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