J
JW73
Is there a way to auto-adjust the range settings for when you add/delete rows
to an Excel sheet? I'm trying to set up an easy way for end-users to
show/hide blocks of information with a button, and I'm using the code below
for each button:
Private Sub CommandButton1_Click()
Dim myRng As Range
Set myRng = Me.Range("7:12")
myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
End Sub
Now, the problem is that these blocks of info will have extra lines
inserted, which tends to break all of the coding. Is there some sort of
adjustment to the coding that I can make to accomodate for that situation, or
would the best way be to name each group of rows, and have the range set to
the names, letting Excel auto-adjust the name ranges and keeping the code
from breaking that way?
to an Excel sheet? I'm trying to set up an easy way for end-users to
show/hide blocks of information with a button, and I'm using the code below
for each button:
Private Sub CommandButton1_Click()
Dim myRng As Range
Set myRng = Me.Range("7:12")
myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
End Sub
Now, the problem is that these blocks of info will have extra lines
inserted, which tends to break all of the coding. Is there some sort of
adjustment to the coding that I can make to accomodate for that situation, or
would the best way be to name each group of rows, and have the range set to
the names, letting Excel auto-adjust the name ranges and keeping the code
from breaking that way?