Maybe there are only 26 cells in the range.
Maybe you have the Apple equivalent of Excel 97.
You haven't said what Excel version you are using.
The MS articles are pretty straight forward.
I doubt if I could be any clearer.
Of course (always), there could be some other issue afoot.
'--
Jim Cone
San Francisco, USAhttp://
www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
"Excel-General"
<
[email protected]>
wrote in message
Jim:
I read your posts on the overflow error in Excel 2003. I am sure that
is the problem
After 26 rows it crashes. If I put wb.Save in the for each loop it
doesn't crash but it still stops on the 26th row. I even tried saveAs
another file after every iteration. it is ugly but it just has to
work because you have to keep clicking okay. The problem with that
was it saved itself as another file and then I couldn't close it.
I could not figure out how to implement Microsoft's workarounds with
this.
Public Sub cpyAllPatientsShts()
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
Set rng = ws.Range("C1:C" & lngLastRow)
inputDate = InputBox("Enter a date:", "Date", Date)
For Each c In rng.Cells
wb.Sheets(2).Copy before:=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
Thanks if you can help.
Janis