Gregg Wolin
Member
I am experimenting with various UI designs for a model I have and have been learning (slowly) some VBA in the process to deal with navigation. I have been setting up various subs to hide columns based on the value of one or more inputs but whenever I move something on the sheet, the references in the code don't move (I assume it has to do with relative vs. absolute referencing). Is it possible to define a column as a range so that my macro isnt affected by rows or columns moving around in the worksheet as i refine it?
I am currently been accomplishing one such task with the following code:
If Range("E15").Value = 0 Then
Columns("P").EntireColumn.Hidden = True
Else
Columns("P").EntireColumn.Hidden = False
However, if i add or delete, any columns that precede "P", i have to go in and update the code. Can i define certain columns (or groups of columns) as a range that can be hidden so that no matter I do, the code hides the "defined" column(s)?
I am currently been accomplishing one such task with the following code:
If Range("E15").Value = 0 Then
Columns("P").EntireColumn.Hidden = True
Else
Columns("P").EntireColumn.Hidden = False
However, if i add or delete, any columns that precede "P", i have to go in and update the code. Can i define certain columns (or groups of columns) as a range that can be hidden so that no matter I do, the code hides the "defined" column(s)?