#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default stumped!!

I have this code that adds sheets to my workbook i would like to add each
sheet name that is added to a sheet in my workbook.
sheet name data column y starting at row 2

Private Sub CommandButton3_Click()
Dim LastCell As Range, Rng As Range, cell As Range
Dim ws As Worksheet

Set ws = wksData
Set LastCell = ws.Cells(Rows.Count, "O").End(xlUp)
Set Rng = ws.Range("O2", LastCell)
For Each cell In Rng
If Not cell.Value = "" Then
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(cell.Value)
On Error GoTo 0
If ws Is Nothing Then
wksMaster.Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Visible = True
ActiveSheet.Name = cell.Value & cell.Offset(0, 1).Value

Range("I3").Value = cell.Offset(0, 2).Value
End If
End If
Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default stumped!!

Haven't delved into your code, but this should work. Below your
ActiveSheet.Name line, place something like this:
Dim lRow As Long
With Sheets("data")
lRow = .Cells(.Rows.Count, "y").End(xlUp).Row
.Cells(lRow + 1, "y").Value = ActiveSheet.Name
End With

jhyatt wrote:
I have this code that adds sheets to my workbook i would like to add each
sheet name that is added to a sheet in my workbook.
sheet name data column y starting at row 2

Private Sub CommandButton3_Click()
Dim LastCell As Range, Rng As Range, cell As Range
Dim ws As Worksheet

Set ws = wksData
Set LastCell = ws.Cells(Rows.Count, "O").End(xlUp)
Set Rng = ws.Range("O2", LastCell)
For Each cell In Rng
If Not cell.Value = "" Then
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(cell.Value)
On Error GoTo 0
If ws Is Nothing Then
wksMaster.Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Visible = True
ActiveSheet.Name = cell.Value & cell.Offset(0, 1).Value

Range("I3").Value = cell.Offset(0, 2).Value
End If
End If
Next

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default stumped!!

Thank you Jw it worked great

"JW" wrote:

Haven't delved into your code, but this should work. Below your
ActiveSheet.Name line, place something like this:
Dim lRow As Long
With Sheets("data")
lRow = .Cells(.Rows.Count, "y").End(xlUp).Row
.Cells(lRow + 1, "y").Value = ActiveSheet.Name
End With

jhyatt wrote:
I have this code that adds sheets to my workbook i would like to add each
sheet name that is added to a sheet in my workbook.
sheet name data column y starting at row 2

Private Sub CommandButton3_Click()
Dim LastCell As Range, Rng As Range, cell As Range
Dim ws As Worksheet

Set ws = wksData
Set LastCell = ws.Cells(Rows.Count, "O").End(xlUp)
Set Rng = ws.Range("O2", LastCell)
For Each cell In Rng
If Not cell.Value = "" Then
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(cell.Value)
On Error GoTo 0
If ws Is Nothing Then
wksMaster.Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Visible = True
ActiveSheet.Name = cell.Value & cell.Offset(0, 1).Value

Range("I3").Value = cell.Offset(0, 2).Value
End If
End If
Next

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
This has me stumped wild turkey no9 Excel Discussion (Misc queries) 5 March 14th 10 03:16 AM
Still stumped LarryK Excel Worksheet Functions 7 March 30th 09 11:15 AM
stumped LarryK Excel Worksheet Functions 4 March 28th 09 05:54 PM
Still Stumped justme Excel Programming 2 January 16th 07 05:29 AM
stumped ?? my Excel Worksheet Functions 2 April 13th 06 12:32 PM


All times are GMT +1. The time now is 06:55 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"