ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting or Deleting Rows (https://www.excelbanter.com/excel-programming/399897-inserting-deleting-rows.html)

Steved

Inserting or Deleting Rows
 
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


Dave Peterson

Inserting or Deleting Rows
 
Can you name the ranges instead?

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



Steved wrote:

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


--

Dave Peterson

Steved

Inserting or Deleting Rows
 
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.

"Dave Peterson" wrote:

Can you name the ranges instead?

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



Steved wrote:

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


--

Dave Peterson


Dave Peterson

Inserting or Deleting Rows
 
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

Steved wrote:

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.

"Dave Peterson" wrote:

Can you name the ranges instead?

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



Steved wrote:

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


--

Dave Peterson


--

Dave Peterson

Steved

Inserting or Deleting Rows
 
Excellent Value

I Thankyou.

"Dave Peterson" wrote:

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

Steved wrote:

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.

"Dave Peterson" wrote:

Can you name the ranges instead?

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



Steved wrote:

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

--

Dave Peterson


--

Dave Peterson



All times are GMT +1. The time now is 12:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com