Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro again...

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
WANT TO HAVE A SUM OF THE NEGATIVE VALUES AND POSITIVE VALUES...how do
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 04:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"