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: 8
Default creating sheets macro crashes after 26th sheet

I need this macro to be a little more robust. It works but only up to
26. Could it be the computer I'm on? If I change the range in the
patient's sheet to only c1:c26 this macro works without a hitch. If I
add any more rows it crashes. i need it to copy all the sheets and
get this done. It is rather urgent. Can I use an array instead of a
loop. Any ideas?
many thanks,

Dim lngLastRow As Long
Dim ws As Worksheet
Dim wb As Workbook
Dim c As Range
Dim rng As Range
Dim sStr As String, Lname As String
Dim inputDate As Date

Set wb = ThisWorkbook
Set ws = wb.Worksheets("patients")
Set ws = ThisWorkbook.Worksheets("patients")

'lngLastRow = Cells(Rows.Count, "c").End(xlUp).Row
' lngLastRow = ws.Cells.Find(What:="*", After:=ws.Range("C1"), _
SearchDirection:=xlPrevious).Row
lngLastRow = ws.Cells.Find("*", SearchOrder:=xlByRows,
SearchDirection:=xlPrevious).Row
Debug.Print lngLastRow
Set rng = ws.Range("C1:C" & lngLastRow)

inputDate = InputBox("Enter a date:", "Date", Date)
For Each c In rng.Cells

wb.Sheets(2).Copy befo=wb.Sheets(2)
Set ws = wb.Sheets(2)

ws.Range("T5") = inputDate
sStr = c
Lname = Mid(sStr, InStr(1, sStr, " ") + 1)
ws.Name = Lname
Next c
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto creating an idex sheet when adding formatted sheets Narnimar Excel Discussion (Misc queries) 15 January 8th 08 06:29 PM
creating multiple sheets, then individualized workbooks for each sheet [email protected] Excel Discussion (Misc queries) 3 November 4th 07 07:13 PM
protect all sheets macro crashes when sheet is hidden Dean[_8_] Excel Programming 9 January 31st 07 09:30 PM
Q: Creating a macro to sort and group columns in a sheet according to another sheet [email protected] Excel Programming 0 January 8th 07 09:06 PM
creating a master sheet that totals values from other sheets robert Excel Programming 2 May 4th 04 04:06 PM


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