ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   inserting and naming range (https://www.excelbanter.com/excel-programming/386117-inserting-naming-range.html)

brownti via OfficeKB.com

inserting and naming range
 
I have the following start to some code. I want to insert a copy of the
range baluster_blank above it and name it baluster1, unless that name is
already being used, in which case baluster2, unless that is used and then
baluster3, and so on.
Sub insertbalusterrow()
Dim rng As Range
Set rng = Range("baluster_blank")
rng.Copy
rng.Insert 1, yes

Where should i go from here? THanks.

--
Message posted via http://www.officekb.com


Don Guillett

inserting and naming range
 
I'm not sure this is what you really want but test with a cell named "bal"
before changing.

Sub copyrangeandname()
With Range("bal")
.Offset(1).Insert
i = 1
On Error GoTo nameit
mn = ThisWorkbook.Names("bal" & i).Name
mn = (Err.Number = 0)
i = i + 1
nameit:
.Offset(1).Name = "bal" & i
End With
End Sub

--
Don Guillett
SalesAid Software

"brownti via OfficeKB.com" <u31540@uwe wrote in message
news:6fcf296b6af28@uwe...
I have the following start to some code. I want to insert a copy of the
range baluster_blank above it and name it baluster1, unless that name is
already being used, in which case baluster2, unless that is used and then
baluster3, and so on.
Sub insertbalusterrow()
Dim rng As Range
Set rng = Range("baluster_blank")
rng.Copy
rng.Insert 1, yes

Where should i go from here? THanks.

--
Message posted via
http://www.officekb.com




brownti via OfficeKB.com

inserting and naming range
 
yea- i adapted that and got it working right. thanks!



Don Guillett wrote:
I'm not sure this is what you really want but test with a cell named "bal"
before changing.

Sub copyrangeandname()
With Range("bal")
.Offset(1).Insert
i = 1
On Error GoTo nameit
mn = ThisWorkbook.Names("bal" & i).Name
mn = (Err.Number = 0)
i = i + 1
nameit:
.Offset(1).Name = "bal" & i
End With
End Sub

I have the following start to some code. I want to insert a copy of the
range baluster_blank above it and name it baluster1, unless that name is

[quoted text clipped - 7 lines]

Where should i go from here? THanks.


--
Message posted via http://www.officekb.com



All times are GMT +1. The time now is 12:07 AM.

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