Inserting or Deleting Rows

S

Steved

Hello from Steved

When I insert or delete Rows I have to go and Change
Set myRng = Me.Range("A40:A42") ie "A39:A41" ( I have over 500 off them )

Is it possibel to modify the below so that If I insert or delete I don't
have to change the bottom. Thankyou.

Private Sub CommandButton6_Click()
Dim myRng As Range
Set myRng = Me.Range("A40:A42")
myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
End Sub
 
D

Dave Peterson

Can you name the ranges instead?

Can you clear the contents and/or hide the rows instead?
 
S

Steved

Hello Dave from Steved

I've forgotten how to do a name Range.
Yes it makes sence because If I delete or insert It will not matter because
has a given name please give me an example. I thankyou.
 
D

Dave Peterson

Insert|Name|Define
'Sheet 1'!yournamehere

or in code:

with worksheets("Sheet9999")
.range("a1:b99").name = "'" & .name & "'!yournamehere"
end with

I'd use worksheet level names.

Since you're working with names, get Jan Karel Pieterse's (with Charles Williams
and Matthew Henson) Name Manager:

You can find it at:
NameManager.Zip from http://www.oaltd.co.uk/mvp
 
S

Steved

Excellent Value

I Thankyou.

Dave Peterson said:
Insert|Name|Define
'Sheet 1'!yournamehere

or in code:

with worksheets("Sheet9999")
.range("a1:b99").name = "'" & .name & "'!yournamehere"
end with

I'd use worksheet level names.

Since you're working with names, get Jan Karel Pieterse's (with Charles Williams
and Matthew Henson) Name Manager:

You can find it at:
NameManager.Zip from http://www.oaltd.co.uk/mvp
 

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