ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Please help me refer to a fixed value. (https://www.excelbanter.com/excel-programming/364727-please-help-me-refer-fixed-value.html)

funkymonkUK[_189_]

Please help me refer to a fixed value.
 

Hi

I have a value in workbook which I would like to use a lot of times
without typing in DIM Var as string then Var =
Sheets("Sheet1").range("A1").value in every single sub that I have.

How could I refer to this figure and save time/ my fingers from typing
exactly the same process?


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=553325


Charlie

Please help me refer to a fixed value.
 
if you Dim the variable at the top of the module (in the General section) it
will be visible to all sub/functions in that module, and if you declare it
"Public" it will be visible in the subs of the sheets/workbook, etc.

"funkymonkUK" wrote:


Hi

I have a value in workbook which I would like to use a lot of times
without typing in DIM Var as string then Var =
Sheets("Sheet1").range("A1").value in every single sub that I have.

How could I refer to this figure and save time/ my fingers from typing
exactly the same process?


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=553325



AA2e72E

Please help me refer to a fixed value.
 
You could try:

Public Function ThisValue() as String
ThisValue=Sheets("Sheet1").range("A1").value
End Function

You will still have to type ThisValue may times!

funkymonkUK[_190_]

Please help me refer to a fixed value.
 

Charlie Wrote:
if you Dim the variable at the top of the module (in the General
section) it
will be visible to all sub/functions in that module, and if you declare
it
"Public" it will be visible in the subs of the sheets/workbook, etc.
[/color]

How do I do the "Public" one?


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=553325


funkymonkUK[_191_]

Please help me refer to a fixed value.
 

i tried putting the following on the top of one of my Modules

Public Const noStores As Integer = Sheets("menu").Range("c7").Value

and within my proceduce

I have

sub test

msgbox noStores
End

but it does not pick up a value for noStores and says Compile error :
constant expression required

where am i going wrong?


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=553325


funkymonkUK[_192_]

Please help me refer to a fixed value.
 

can anybody help me?


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=553325



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

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