VBA set and call public value from formula

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,185
Hi,

I have different sheets that use a cell named "RngYear" to calculate dates. So when I change RngYear from 2018 to 2019, all dates are updated
Code:
=Date(RngYear,A1,B1)[/FONT][/COLOR][COLOR=#222222][FONT=Verdana]
To do so, I have a dropdowdown menu in my ribbon that change the value Range("RngYear") with the value of the dropdown

What annoys me is to have that cell "RngYear" in my workbook. Instead, can I not write the value in the "backstage" (a constant "CstYear" that would change when I update the dropdown) and that I could call from a formula such as
Code:
=Date(CstYear,A1,B1)[/FONT][/COLOR][COLOR=#222222][FONT=Verdana]
?

Thanks in advance for your help
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hey, I was not aware of that! It never crossed my mind! Thank you very much!

I change the cell reference with = 2018 in name manager and then only had to change my macro from
Code:
[COLOR=#222222][FONT=Verdana].Range("RngYear").value=2019[/FONT][/COLOR]
to
Code:
[COLOR=#222222][FONT=Verdana].Names("[/FONT][/COLOR]RngYear").value= 2019

It will save me the headaches of difficult protections from user. Thanks again!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,980
Members
448,934
Latest member
audette89

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