Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to lock and unlock a cell using formulas in excel Ridhi Excel Discussion (Misc queries) 1 April 19th 08 11:33 AM
How do i add multiple formulas in one cell for excel? M Excel Discussion (Misc queries) 4 July 18th 07 09:42 PM
How do I reference a cell in another document in Excel formulas? Aurielle Excel Discussion (Misc queries) 3 July 12th 07 03:53 PM
Excel: Clear all cell entries EXCEPT formulas? newsgal Excel Discussion (Misc queries) 6 March 18th 06 12:46 AM
Excel should let me do absolute copies of cell formulas muchado Excel Discussion (Misc queries) 0 January 11th 06 08:39 AM


All times are GMT +1. The time now is 09:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"