ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unreachable public variables (https://www.excelbanter.com/excel-programming/328934-unreachable-public-variables.html)

Gary's Student

Unreachable public variables
 
I define a group of public variables. I have a macro that initializes them.
They work fine through all my functions and subs. I have not found a way to
get my formulas in cells to see them. For example =A1*pi won't work. My
workaround has been to stick the value of pi in a cell and use a named range.
What's the real solution to using public vaiables in cell formulas??
--
Gary's Student

Tushar Mehta

Unreachable public variables
 
Variables are VBA variables and visible only within VBA code. To make
them accessible from XL, create public functions that are then used as
user-defined-functions.' Do keep in mind that XL itself supports many
functions natively, including PI()

Const cPi=3.1415927
public function Pi():pi=cpi:end function

Then, in some cell, use =Pi()


--
Regards,

Tushar Mehta
www.tushar-mehta.com
Multi-disciplinary business expertise
+ Technology skills
= Optimal solution to your business problem
Recipient Microsoft MVP award 2000-2005

In article ,
says...
I define a group of public variables. I have a macro that initializes them.
They work fine through all my functions and subs. I have not found a way to
get my formulas in cells to see them. For example =A1*pi won't work. My
workaround has been to stick the value of pi in a cell and use a named range.
What's the real solution to using public vaiables in cell formulas??


Bob Phillips[_7_]

Unreachable public variables
 
Notwithstanding that Excel has a PI() function, if you want worksheet
constants like that, create a workbook name with that name and the required
value.

--
HTH

Bob Phillips

"Gary's Student" wrote in message
...
I define a group of public variables. I have a macro that initializes

them.
They work fine through all my functions and subs. I have not found a way

to
get my formulas in cells to see them. For example =A1*pi won't work. My
workaround has been to stick the value of pi in a cell and use a named

range.
What's the real solution to using public vaiables in cell formulas??
--
Gary's Student





All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com