Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Using Excel VBA can a constant be available to multiple projects? -- lcoreyl ------------------------------------------------------------------------ lcoreyl's Profile: http://www.excelforum.com/member.php...fo&userid=2042 View this thread: http://www.excelforum.com/showthread...hreadid=552950 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not usually. You would need to set a reference from the workbooks that want
to use the constant to the workbook that defines the constant. Probably not something you want to do. A possible workaround could be: In the workbook that contains the constant, you could put a sub that returns its value In a general module a workbook named ABC.xls as an example. Public Const MyVal as Long = 10 Pubic Function ReturnMyVal() ReturnMyVal = MyVal End Function then in the other workbook v = Application.Run( "ABC.xl1!ABC") msgbox v now v will hold the value of the constant. -- Regards, Tom Ogilvy "lcoreyl" wrote in message ... Using Excel VBA can a constant be available to multiple projects? -- lcoreyl ------------------------------------------------------------------------ lcoreyl's Profile: http://www.excelforum.com/member.php...fo&userid=2042 View this thread: http://www.excelforum.com/showthread...hreadid=552950 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() keep getting "macro not found" tried creating (in the book with the constant) a macro named ABC wit just the function in it, and still get the same error.. -- lcorey ----------------------------------------------------------------------- lcoreyl's Profile: http://www.excelforum.com/member.php...nfo&userid=204 View this thread: http://www.excelforum.com/showthread.php?threadid=55295 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There was a typo on the Application.Run string and in the spelling of Public
for the function - but fixing those I recreated the situation In the workbook named ABC.xls, in Module1 Public Const MyVal As Long = 10 Public Function ReturnMyVal() ReturnMyVal = MyVal End Function in another workbook Sub GettheValue() v = Application.Run("ABC.xls!ReturnMyVal") MsgBox v End Sub the message box displayed 10 -- Regards, Tom Ogilvy "lcoreyl" wrote in message ... keep getting "macro not found" tried creating (in the book with the constant) a macro named ABC with just the function in it, and still get the same error... -- lcoreyl ------------------------------------------------------------------------ lcoreyl's Profile: http://www.excelforum.com/member.php...fo&userid=2042 View this thread: http://www.excelforum.com/showthread...hreadid=552950 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I copied those directly into two workbooks and it still doesn't work. It does open ABC.xls, but then says "The macro 'ABC.xls!ReturnMyVal can not be found" -- lcorey ----------------------------------------------------------------------- lcoreyl's Profile: http://www.excelforum.com/member.php...nfo&userid=204 View this thread: http://www.excelforum.com/showthread.php?threadid=55295 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Now it is working. I thought I needed the path of the ABC in th application run command, and eveidently that messes it up, although i does open ABC, but then not the macro. I just copied exactly what yo had and now it works.. -- lcorey ----------------------------------------------------------------------- lcoreyl's Profile: http://www.excelforum.com/member.php...nfo&userid=204 View this thread: http://www.excelforum.com/showthread.php?threadid=55295 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditional format to highlight only cells with formula, not const | Excel Worksheet Functions | |||
relative path for const in vba code | Excel Programming | |||
Not recognizing a Const | Excel Programming | |||
Public Const on a Drive | Excel Programming | |||
crash changing const to public const | Excel Programming |