Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Adding a New Tab-and Naming it from a Cell Name

All I am trying to add a new worksheet and name it what ever the cell value
is from my main sheet. The name will always be a number plus one. Example
in my "Inputsheet' in column BA row 9 is a number 1701, so with what I am
trying to do is ref BA9 and copy it to BA10 plus one (cell BA10 then should
say 1702).

I have attached my code which is not working (got part of this code from Ron
de Bruin web site):

Private Sub CreateNewSheet1_Click()
Dim LastRow As Long
Dim rng As Range

With ActiveSheet
LastRow = .Cells(.Rows.Count, "BA").End(xlUp).Row
With rng.Parent
.Select
.Range(LastRow).Select
End With
LastRow = ActiveCell.FormulaR1C1 = "=R[-1]C+1"
Selection.Copy
ActiveSheet.Range(LastRow).Select
ActiveSheet.Paste

End With

Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = LastRow

ActiveSheet.Range("A1").Select

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Adding a New Tab-and Naming it from a Cell Name

Hi

Look at this:

Private Sub CreateNewSheet1_Click()
Dim LastRow As Long

LastRow = Cells(Rows.Count, "BA").End(xlUp).Row
Range("BA" & LastRow + 1) = Range("BA" & LastRow).Value + 1

NewShName = Range("BA" & LastRow + 1).Value

Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = NewShName
End Sub

Regards,
Per

"caldog" skrev i meddelelsen
...
All I am trying to add a new worksheet and name it what ever the cell
value
is from my main sheet. The name will always be a number plus one.
Example
in my "Inputsheet' in column BA row 9 is a number 1701, so with what I am
trying to do is ref BA9 and copy it to BA10 plus one (cell BA10 then
should
say 1702).

I have attached my code which is not working (got part of this code from
Ron
de Bruin web site):

Private Sub CreateNewSheet1_Click()
Dim LastRow As Long
Dim rng As Range

With ActiveSheet
LastRow = .Cells(.Rows.Count, "BA").End(xlUp).Row
With rng.Parent
.Select
.Range(LastRow).Select
End With
LastRow = ActiveCell.FormulaR1C1 = "=R[-1]C+1"
Selection.Copy
ActiveSheet.Range(LastRow).Select
ActiveSheet.Paste

End With

Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = LastRow

ActiveSheet.Range("A1").Select

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Adding a New Tab-and Naming it from a Cell Name


Worked great Thanks
"Per Jessen" wrote:

Hi

Look at this:

Private Sub CreateNewSheet1_Click()
Dim LastRow As Long

LastRow = Cells(Rows.Count, "BA").End(xlUp).Row
Range("BA" & LastRow + 1) = Range("BA" & LastRow).Value + 1

NewShName = Range("BA" & LastRow + 1).Value

Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = NewShName
End Sub

Regards,
Per

"caldog" skrev i meddelelsen
...
All I am trying to add a new worksheet and name it what ever the cell
value
is from my main sheet. The name will always be a number plus one.
Example
in my "Inputsheet' in column BA row 9 is a number 1701, so with what I am
trying to do is ref BA9 and copy it to BA10 plus one (cell BA10 then
should
say 1702).

I have attached my code which is not working (got part of this code from
Ron
de Bruin web site):

Private Sub CreateNewSheet1_Click()
Dim LastRow As Long
Dim rng As Range

With ActiveSheet
LastRow = .Cells(.Rows.Count, "BA").End(xlUp).Row
With rng.Parent
.Select
.Range(LastRow).Select
End With
LastRow = ActiveCell.FormulaR1C1 = "=R[-1]C+1"
Selection.Copy
ActiveSheet.Range(LastRow).Select
ActiveSheet.Paste

End With

Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = LastRow

ActiveSheet.Range("A1").Select

End Sub



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding, naming Worksheets sequentially Sol Apache Excel Programming 4 March 30th 07 02:36 PM
Making for adding and naming a new sheet michaelberrier Excel Discussion (Misc queries) 13 May 29th 06 07:58 PM
Adding and naming new worksheets Byron[_5_] Excel Programming 1 September 9th 05 05:21 AM
Adding and Naming Multiple Worksheets Byron Excel Worksheet Functions 6 September 8th 05 02:52 AM
Naming and Adding Worksheets Brenda Excel Programming 2 February 3rd 05 10:37 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"