P
parteegolfer
if I run the below Macro for a second time, a duplicate row will be
inserted below the last one that was inserted. How can I keep this from
happining.
Here is the code I am currently running
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)))
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
End Sub
inserted below the last one that was inserted. How can I keep this from
happining.
Here is the code I am currently running
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)))
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
End Sub