LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default help please

i have the following code that worked fine until this morning. it is now
stopping at the following line.

wksMaster.Copy after:=Worksheets(Worksheets.Count)

is there a limit to the number of sheets that you create in a workbook. the
reason i ask is while testing the code i would run it and then delete the
sheets. but now it wont get passed this line.

any help would be appreciated



Private Sub Addsheets()
Dim LastCell As Range, Rng As Range, cell As Range
Dim ws As Worksheet
Dim lRow As Long

ActiveWorkbook.Unprotect Password:="53476"
Set ws = wksData
Set LastCell = ws.Cells(Rows.Count, "l").End(xlUp)
Set Rng = ws.Range("l2", LastCell)
wksTotals.Range("b5").Value = wksData.Range("L1")
Application.Goto Reference:="worksheetname"
Selection.ClearContents
Application.Goto Reference:="totalslist"
Selection.ClearContents
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
With Sheets("data")
lRow = .Cells(.Rows.Count, "V").End(xlUp).Row
.Cells(lRow + 1, "V").Value = ActiveSheet.Name
End With
With Sheets("data")
lRow = .Cells(.Rows.Count, "w").End(xlUp).Row
.Cells(lRow + 1, "w").Value = "='" &
ActiveSheet.Name & "'!k30"
End With
With Sheets("data")
lRow = .Cells(.Rows.Count, "x").End(xlUp).Row
.Cells(lRow + 1, "x").Value = "='" &
ActiveSheet.Name & "'!L30"
End With
With Sheets("data")
lRow = .Cells(.Rows.Count, "Y").End(xlUp).Row
.Cells(lRow + 1, "Y").Value = "='" &
ActiveSheet.Name & "'!m30"
End With
With Sheets("data")
lRow = .Cells(.Rows.Count, "z").End(xlUp).Row
.Cells(lRow + 1, "z").Value = "='" &
ActiveSheet.Name & "'!R30"
End With
With Sheets("data")
lRow = .Cells(.Rows.Count, "aa").End(xlUp).Row
.Cells(lRow + 1, "aa").Value = "='" &
ActiveSheet.Name & "'!S30"
End With
With Sheets("data")
lRow = .Cells(.Rows.Count, "ab").End(xlUp).Row
.Cells(lRow + 1, "ab").Value = "='" &
ActiveSheet.Name & "'!T30"
End With
With Sheets("data")
lRow = .Cells(.Rows.Count, "ac").End(xlUp).Row
.Cells(lRow + 1, "ac").Value = "='" &
ActiveSheet.Name & "'!V30"
End With
Range("I3").Value = cell.Offset(0, 2).Value
End If
End If
Next
wksTotals.Activate
wksTotals.Name = Range("b5").Value & "Totals"
ActiveWorkbook.Protect Password:="53476"
End Sub

 
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



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

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

About Us

"It's about Microsoft Excel"