Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default references between macros not working

I have a number of macros that I am using to perform a number of functions
within a workbook.
As part of that, I am using code to name cells with the idea that I would be
able tor reference the cell values later. According to the vba intermediate
window it works - until that macro ends. The very next macro that runs, even
within the module, does not retrieve the info from the cell referenced by
name.
I have no idea what I am doing wrong. I would try using a "public"
statement except I can't get those to work either. As far as I can tell,
their is no difference in syntax between a public statement and a dim
statement other than the word "public" instead of "dim".
The public thing may be a red herring anyway.

Please help!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default references between macros not working

Help with what?

You don't show any code.

In a new module put in code like this

Public MyName as String

Sub SetMyName()
Activecell.Name = "ABCD"
MyName = "ABCD"
End Sub

Sub ShowMyName()
msgbox Range(MyName).Address & " " & MyName
End sub

Perhaps that will give you some ideas. Using Public within a procedure will
have no effect. A public variable must be declared at the top of the module,
outside any procedure.

--
Regards,
Tom Ogilvy

"Papa Jonah" wrote in message
...
I have a number of macros that I am using to perform a number of functions
within a workbook.
As part of that, I am using code to name cells with the idea that I would

be
able tor reference the cell values later. According to the vba

intermediate
window it works - until that macro ends. The very next macro that runs,

even
within the module, does not retrieve the info from the cell referenced by
name.
I have no idea what I am doing wrong. I would try using a "public"
statement except I can't get those to work either. As far as I can tell,
their is no difference in syntax between a public statement and a dim
statement other than the word "public" instead of "dim".
The public thing may be a red herring anyway.

Please help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default references between macros not working

Thanks for your help Tom,
I have been playing with your code.
I am successful in some variations such as:
I can use code to name a cell. I can use code to perform a calculation.

Let's say that I name a cell "ABCD" and it contains the number 6. I have a
public statement at the beginning of the module that reads Public mynumber as
integer.

From here, I can enter "=ABCD" in another cell and get 6. That is what I
want.

In your code, "myname" was entered by the code-writer.

I think my trouble is:
I want code to read the value that the user enters into ABCD so that it can
be used in a calculation. Essentially, I want the code to automatically
enter the "=ABCD" for me.

Papa

"Tom Ogilvy" wrote:

Help with what?

You don't show any code.

In a new module put in code like this

Public MyName as String

Sub SetMyName()
Activecell.Name = "ABCD"
MyName = "ABCD"
End Sub

Sub ShowMyName()
msgbox Range(MyName).Address & " " & MyName
End sub

Perhaps that will give you some ideas. Using Public within a procedure will
have no effect. A public variable must be declared at the top of the module,
outside any procedure.

--
Regards,
Tom Ogilvy

"Papa Jonah" wrote in message
...
I have a number of macros that I am using to perform a number of functions
within a workbook.
As part of that, I am using code to name cells with the idea that I would

be
able tor reference the cell values later. According to the vba

intermediate
window it works - until that macro ends. The very next macro that runs,

even
within the module, does not retrieve the info from the cell referenced by
name.
I have no idea what I am doing wrong. I would try using a "public"
statement except I can't get those to work either. As far as I can tell,
their is no difference in syntax between a public statement and a dim
statement other than the word "public" instead of "dim".
The public thing may be a red herring anyway.

Please help!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default references between macros not working

I figured it out Tom.
Instead of trying to refer to the value of ABCD, I needed to use the
formular1c1="=abcd" statement.
Thanks.

"Tom Ogilvy" wrote:

Help with what?

You don't show any code.

In a new module put in code like this

Public MyName as String

Sub SetMyName()
Activecell.Name = "ABCD"
MyName = "ABCD"
End Sub

Sub ShowMyName()
msgbox Range(MyName).Address & " " & MyName
End sub

Perhaps that will give you some ideas. Using Public within a procedure will
have no effect. A public variable must be declared at the top of the module,
outside any procedure.

--
Regards,
Tom Ogilvy

"Papa Jonah" wrote in message
...
I have a number of macros that I am using to perform a number of functions
within a workbook.
As part of that, I am using code to name cells with the idea that I would

be
able tor reference the cell values later. According to the vba

intermediate
window it works - until that macro ends. The very next macro that runs,

even
within the module, does not retrieve the info from the cell referenced by
name.
I have no idea what I am doing wrong. I would try using a "public"
statement except I can't get those to work either. As far as I can tell,
their is no difference in syntax between a public statement and a dim
statement other than the word "public" instead of "dim".
The public thing may be a red herring anyway.

Please help!




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
Cell references not working RiteshB Excel Discussion (Misc queries) 2 August 12th 09 09:51 PM
working with references of cells Diana Excel Worksheet Functions 1 April 9th 05 01:08 PM
External References not working right. Dread_Pirate_Roberts Excel Worksheet Functions 13 December 8th 04 11:07 PM
Relative References for macros Grace[_4_] Excel Programming 5 June 10th 04 06:09 PM
References in VBA macros ? KajBre Excel Programming 3 October 28th 03 01:43 PM


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

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"