Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stuck on Formula
I have this code that detects the end of a workweek by date in colum (A)and when the Macro is run it inserts a row with "Weekly Subtotal" i column (A). There are two issues I can't figuire out: 1) I need to sum up columns above each row till the next "Weekl Subtotal" is detected. - Coulmns D, E, and F 2) The way the code is now, if I run the Macro for a second time, duplicate row will be inserted below the last one that was inserted How can I keep this from happining. Here is the code: 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 Su -- parteegolfe ----------------------------------------------------------------------- parteegolfer's Profile: http://www.excelforum.com/member.php...fo&userid=3195 View this thread: http://www.excelforum.com/showthread.php?threadid=51935 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stuck on a Formula | Excel Discussion (Misc queries) | |||
stuck up with a formula | Excel Discussion (Misc queries) | |||
stuck for a formula | Excel Discussion (Misc queries) | |||
Stuck on formula | Excel Discussion (Misc queries) | |||
Formula Help... I'm really stuck here | Excel Discussion (Misc queries) |