Using defined names with range.formula property

DaveBlakeMAAT

Board Regular
Joined
Feb 28, 2016
Messages
190
Hi all

I currently have a formula as listed below within my VBA script which all works great, however, when it populates the formula into the cell it inserts the underlying value of the named range instead of referencing the named range. The named range "MinimumIncomeThreshold" is pointing to an individual cell.

This means that the formula is not dynamic!

Code:
Range("M3", LastFormulaCell).Formula = "=IF(B3<" & [COLOR="#FF0000"]Range("MinimumIncomeThreshold")[/COLOR] & ",""Below Threshold"",MATCH(A3,list!$A$2:$A$1048576,0)+1)"

Does anyone know how I can correct this?

ps: I do not want to reference the cell address directly in my VBA code as this will break if someone decides to be "helpful" and insert new rows!!

Regards

Dave
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Dave

Try this.
Code:
Range("M3", LastFormulaCell).Formula = "=IF(B3<MinimumIncomeThreshold ,""Below Threshold"",MATCH(A3,list!$A$2:$A$1048576,0)+1)"
 
Upvote 0
Ach, that's the board doing that.

I'll try again.
Code:
Range("M3", LastFormulaCell).Formula = "=IF(B3 < MinimumIncomeThreshold ,""Below Threshold"",MATCH(A3,list!$A$2:$A$1048576,0)+1)"
 
Upvote 0
Thanks Norie

I am such a muppet at times!!!!

I did try your suggestion originally, but stupidly I was manually changing the wrong cell value when testing.

I appreciate your help.

Regards

Dave
 
Upvote 0

Forum statistics

Threads
1,215,741
Messages
6,126,597
Members
449,320
Latest member
Antonino90

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