View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Error 13 when macro run more than once

Here is a slightly different approach ( I made lots of assumptions).
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

'-------------------
Sub WeekdayCountRevised()
Dim rngCell As Excel.Range
Dim rngSum As Excel.Range
Dim i As Long
Dim lngR As Long

Set rngCell = Range("A8")
lngR = rngCell.Row

Do
If IsDate(rngCell(2, 1)) Then
If Weekday(rngCell(2, 1).Value) < Weekday(rngCell.Value) Then
rngCell(2, 1).EntireRow.Insert
rngCell(2, 1).Value = "Weekly Subtotal"

For i = 2 To 5
Set rngSum = Range(rngCell(1, i), Cells(lngR, i))
rngCell(2, i).Value = Application.Sum(rngSum)
Next i

Set rngCell = rngCell(3, 1)
lngR = rngCell.Row
Else
Set rngCell = rngCell(2, 1)
End If
Else
Set rngCell = rngCell(2, 1)
End If
Loop Until Len(rngCell.Value) = 0

End Sub

'--------------------

"parteegolfer" wrote in message ...This took care of the error message popping up however I have one more
issue. I need to have this macro to continue inserting the row "weekly
subtotal" if dates are entered into column (A) after the macro was
previously run. Can you help with this issue? Currently the macro when
run will detect dates in column (A) and insert a row labeled "Weekly
Subtotal" after every 5 days. If days are entered after the macro is
run nothing happens unless I delete the rows with "weekly Subtotal"
previously inserted. then it will insert all the rows as needed.
Hope this makes sense and hopefully you can Help!
--
parteegolfer