JoelTXCive
Civil/Environmental
- Jul 24, 2016
- 929
I am having difficulty with range objects and global variables.
My overall goal is to have excel store a “FtInch_Hotcell” which is the most recent cell that a sub-routine has been run on. If I call a specific macro, I want to look at my current activecell location and compare it to the cell residing in the “FtInch_Hotcell.” If the cells are the same, then I want to do procedure A with the cell; and if the cells are different, then I want to do procedure B.
Here is what I have so far:
Upon opening a workbook I am declaring a global range object. I have one line of code in a separate module for global items.
'declare the HotCell as variable available to all subroutines
Public FtInch_HotCell As Range
I then assign a single cell to this range object. To start with, I just put a random cell in the FtInch_HotCell range. This occurs in the ‘workbook open’ module.
Set FtInch_HotCell = ActiveSheet.Range("a999")
In a new procedure, how do I compare the current active cell to the cell residing in ‘FtInch_HotCell’
I have tried several different combinations of logical arguments but cannot seem to get it to work. I’m not even sure I am accessing the global variable correctly.
Thank you.
Ps. Really big picture what I am doing is converting decimal feet to feet and inches. When you run the procedure the first time, the output is in 1/64 inches. The second run yields 1/32 inches and then 1/16... etc.. (if i can ever get it to work)
My overall goal is to have excel store a “FtInch_Hotcell” which is the most recent cell that a sub-routine has been run on. If I call a specific macro, I want to look at my current activecell location and compare it to the cell residing in the “FtInch_Hotcell.” If the cells are the same, then I want to do procedure A with the cell; and if the cells are different, then I want to do procedure B.
Here is what I have so far:
Upon opening a workbook I am declaring a global range object. I have one line of code in a separate module for global items.
'declare the HotCell as variable available to all subroutines
Public FtInch_HotCell As Range
I then assign a single cell to this range object. To start with, I just put a random cell in the FtInch_HotCell range. This occurs in the ‘workbook open’ module.
Set FtInch_HotCell = ActiveSheet.Range("a999")
In a new procedure, how do I compare the current active cell to the cell residing in ‘FtInch_HotCell’
I have tried several different combinations of logical arguments but cannot seem to get it to work. I’m not even sure I am accessing the global variable correctly.
Thank you.
Ps. Really big picture what I am doing is converting decimal feet to feet and inches. When you run the procedure the first time, the output is in 1/64 inches. The second run yields 1/32 inches and then 1/16... etc.. (if i can ever get it to work)