Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel cell formulas and VBA
Hello,
On a worksheet, in a cell, with in a formula I need to reference a global variable set in a vba modual. Example: = (a1+z13)*2.537/myvar How is this done? What is the proper term for this? I tried searching on the net, but found nothing. Thank you for your time. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel cell formulas and VBA
Running something like:
Sub Macro1() ActiveWorkbook.Names.Add Name:="myvar", RefersToR1C1:="=5678" End Sub will create and assign a value to a variable that can be used on the worksheet. -- Gary''s Student - gsnu200790 "bteddy" wrote: Hello, On a worksheet, in a cell, with in a formula I need to reference a global variable set in a vba modual. Example: = (a1+z13)*2.537/myvar How is this done? What is the proper term for this? I tried searching on the net, but found nothing. Thank you for your time. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel cell formulas and VBA
A variation of this approach is to define the name through Insert - Names -
Define. Give it the name "myvar" and in the "Refers To" section at the bottom of the window, type in 5678 and click on OK. You've now defined a name, myvar, and given it a value. Under macro control, you can do something like this: Sub Updatemyvar(NewVal As Single) ThisWorkbook.Names("myvar").Value = NewVal End Sub The previous post would be a convenient way to create and initialize the name, if you didn't want to perform this task manually, as described above. "Gary''s Student" wrote: Running something like: Sub Macro1() ActiveWorkbook.Names.Add Name:="myvar", RefersToR1C1:="=5678" End Sub will create and assign a value to a variable that can be used on the worksheet. -- Gary''s Student - gsnu200790 "bteddy" wrote: Hello, On a worksheet, in a cell, with in a formula I need to reference a global variable set in a vba modual. Example: = (a1+z13)*2.537/myvar How is this done? What is the proper term for this? I tried searching on the net, but found nothing. Thank you for your time. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to lock and unlock a cell using formulas in excel | Excel Discussion (Misc queries) | |||
How do i add multiple formulas in one cell for excel? | Excel Discussion (Misc queries) | |||
How do I reference a cell in another document in Excel formulas? | Excel Discussion (Misc queries) | |||
Excel: Clear all cell entries EXCEPT formulas? | Excel Discussion (Misc queries) | |||
Excel should let me do absolute copies of cell formulas | Excel Discussion (Misc queries) |