Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Problem with Public Variable value being changed.

Hi,

I am hoping someone will be able to explain and offer a fix for this
problem I have with a worksheet I am working on.

On the module 1 I declared a public variable RowCount as long.
This variable is assigned in the Open function to find the last row of
data.
I then use it in Sheets1 to add/make changes to values on the
specified RowCount Range.

My problem is that somehwere Rowcount value changes somehow.
I have msgbox's everywhere the Rowcount is modified to keep track of
it and I cant find a reason why it changes.

The only thing I can think of is that I have another worksheet opened
that also has VB code and it might mess up with it, but I dont have
any variable called RowCount.

So I need to fix this. How can I protect the Rowcount so it only
changes where it is supposed to (in this case in the module 1 only)
and that it can be used anywhere in that worksheet only (right now it
only have one sheet called "tracker")

Thanks for the help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Problem with Public Variable value being changed.

Try debugging by putting a watch on that variable and run the code.
This is done in the VBE under Debug, Add watch.

RBS


wrote in message
...
Hi,

I am hoping someone will be able to explain and offer a fix for this
problem I have with a worksheet I am working on.

On the module 1 I declared a public variable RowCount as long.
This variable is assigned in the Open function to find the last row of
data.
I then use it in Sheets1 to add/make changes to values on the
specified RowCount Range.

My problem is that somehwere Rowcount value changes somehow.
I have msgbox's everywhere the Rowcount is modified to keep track of
it and I cant find a reason why it changes.

The only thing I can think of is that I have another worksheet opened
that also has VB code and it might mess up with it, but I dont have
any variable called RowCount.

So I need to fix this. How can I protect the Rowcount so it only
changes where it is supposed to (in this case in the module 1 only)
and that it can be used anywhere in that worksheet only (right now it
only have one sheet called "tracker")

Thanks for the help.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Problem with Public Variable value being changed.

I would set a Watch on the variable. In VBA, go to the Debug menu and choose
Add Watch. In that dialog, enter RowCount as the Expression, select "All
Procedures" in the Procedures drop down, select "All Modules" in the Module
drop down, and select "Break When Value Changes" in the Watch Type option
box. When the value of RowCount changes, VBA will pause on the line of code
that changed the value.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)



wrote in message
...
Hi,

I am hoping someone will be able to explain and offer a fix for this
problem I have with a worksheet I am working on.

On the module 1 I declared a public variable RowCount as long.
This variable is assigned in the Open function to find the last row of
data.
I then use it in Sheets1 to add/make changes to values on the
specified RowCount Range.

My problem is that somehwere Rowcount value changes somehow.
I have msgbox's everywhere the Rowcount is modified to keep track of
it and I cant find a reason why it changes.

The only thing I can think of is that I have another worksheet opened
that also has VB code and it might mess up with it, but I dont have
any variable called RowCount.

So I need to fix this. How can I protect the Rowcount so it only
changes where it is supposed to (in this case in the module 1 only)
and that it can be used anywhere in that worksheet only (right now it
only have one sheet called "tracker")

Thanks for the 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
strange problem with public variable Gary Keramidas Excel Programming 2 July 8th 07 03:58 PM
Public Variable Marvin Excel Programming 1 March 29th 07 09:50 PM
Public variable problem moonhk Excel Programming 13 December 8th 06 08:38 AM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


All times are GMT +1. The time now is 07:48 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"