P
parteegolfer
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
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