inserting and naming range

  • Thread starter brownti via OfficeKB.com
  • Start date
B

brownti via OfficeKB.com

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.
 
D

Don Guillett

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
 
B

brownti via OfficeKB.com

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



Don said:
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.
 

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