×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problem with Public Variable in VBA (Excel97)

Problem with Public Variable in VBA (Excel97)

Problem with Public Variable in VBA (Excel97)

(OP)
I'm having a rough time with a public variable.  Any light you can shed on this matter is greatly appreciated.

Here's what's happening (in Excel 97)


I declare a public variable in "Workbook1.xls"

A sheet is copied from "Workbook1.xls" to  "Workbook2.xls"

Included in this sheet is a Worksheet_Change Procedure which refers to the public variable.

Every time the worksheet in "Workbook2.xls" is changed the public variable is empty.
(Even when the public variable still has a value indicated in my watch expression)

Please note that the change(s) in "Workbook2.xls" always occur while the macro from "Workbook1.xls" is still running.

My project does not require variable declaration.

What I need is a way to access the value of the Public variable in "Worksheet1.xls"

Thanks again,

Matthew

RE: Problem with Public Variable in VBA (Excel97)

Can't you just do something like:

GimmeTheValue = Workbooks("Workbook1.xls").Worksheet("<SheetName>").yourPublicVariable

?

U might have to tinker with it.. like sometimes it has to be Workbook instead of Workbooks... this is off the top of my head.  Basically u need to get to the sheet object in your workbook.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close