Inserting rows

S

Steved

Hello from Steved

I've got a problem and that is when I insert a Row My ranges Set myRng =
Me.Range("A10:A10") will not change ie to Set myRng = Me.Range("A11:A11"),

Is their something I can do as now I've got to go and change every range by 1.
I would like to avoid this in other wordswhen I insert a row the range will
change .
Thankyou.

Private Sub CommandButton1_Click()
Dim myRng As Range
Set myRng = Me.Range("A10:A10")
myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
End Sub

Private Sub CommandButton10_Click()
Dim myRng As Range
Set myRng = Me.Range("A63:A64")
myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
End Sub
 
J

Jim Thomlinson

Sorry but at this point there is no easy solution. What you can do is create
a named range for A10 (which is now A11 I assume) and then do a find and
replace in your code for every instance of A10. Now if you move the ranges
around again the code will move with the range name and all should be well.
 
S

Steved

Hello Jim

Thankyou.

Jim Thomlinson said:
Sorry but at this point there is no easy solution. What you can do is create
a named range for A10 (which is now A11 I assume) and then do a find and
replace in your code for every instance of A10. Now if you move the ranges
around again the code will move with the range name and all should be well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top