Thread: Macro again...
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Macro again...

Dim cell as Range, rng as Range, rng1 as Range
for each cell in Range("K1:K200")
if cell.value < 0 and cell.offset(1,0).Value = 0 then
cell.offset(1,0).EntireRow.Insert
cell.offset(1,0).Formula = "=Sum(K1:" & cell.Address(0,0) & ")"
Cell.offset(1,0).Font.bold = True
exit for
end if
Next
set rng = Cell.Offset(2,0)
set rng1 = cells(rows.count,"K").End(xlup)(2)
rng1.Formula = "=Sum(" & Range(rng,rng1.offset(-1,0)).Address(0,0) & _
")"
rng1.font.bold = True

Untested and may contain typos, but should give you a workable approach.


--
Regards,
Tom Ogilvy

"debra2468 " wrote in message
...
Cells.Select
Selection.Sort Key1:=Range("K2"), Order1:=xlAscending, Header:=xlYes,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

THE ABOVE CODE PUTS THE VALUES IN THE COLUMN IN ASCENDING ORTDER. NOW I
WANT TO HAVE A SUM OF THE NEGATIVE VALUES AND POSITIVE VALUES...how do i
do that ?

eg:

-9
-6
-4

-19----------------------total

2
5
7
8

22-------------------------total

i need to insert the totals and make them bold ..
any clue ???????


---
Message posted from http://www.ExcelForum.com/