Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have an issue when this macro is run more than one I get error 13. at the spot indicated in the VBA below. I don't know how to eleiminate it or ignore if the macro is run multiple times. Can anyone help! Sub weekdaycount() Dim wrng As Range, lrng As Range Dim count As Long Set wrng = Cells(8, "a") '<<=== start range - change if need Set lrng = Cells(Cells.Rows.count, "a").End(xlUp) Do While (wrng.Row <= lrng.Row) count = 1 Do While (Weekday(wrng) <= Weekday(wrng(2)))<<Error 13 Here If wrng(2) < "" Then Set wrng = wrng(2) count = count + 1 Else Exit Do End If Loop Set wrng = wrng(2) wrng.EntireRow.Insert wrng(0) = "Weekly Subtotal" Loop Dim rng As Range Dim lastrow As Long, r As Long, i As Integer With ActiveSheet lastrow = .Cells(Rows.count, "A").End(xlUp).Row r = 1 srow = r Do Do r = r + 1 Loop Until .Cells(r, "a") = "Weekly Subtotal" Or r = lastrow For i = 4 To 7 Set rng = .Range(.Cells(srow, i), .Cells(r - 1, i)) Cells(r, i) = Application.Sum(rng) Next i srow = r + 1 Loop Until srow lastrow End With End Sub -- parteegolfer ------------------------------------------------------------------------ parteegolfer's Profile: http://www.excelforum.com/member.php...o&userid=31951 View this thread: http://www.excelforum.com/showthread...hreadid=521539 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Worksheet Functions | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Discussion (Misc queries) | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
naming tab macro error runtime error 1004 | Excel Programming | |||
Macro 'Automation error' with ChemOffice Excel macro | Excel Programming |