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


Found my own answer.

Sub SumIfer()
Dim EnderA As String
Dim EnderC As String
Dim EnderD As String
Dim EnderE As Variant
Dim Acta As String

Range("A6").Select
Selection.Sort Key1:=Range("A6"), Order1:=xlAscending
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A7").Select
EnderA = Range(Selection, Selection.End(xlDown)).Address
Debug.Print EnderA
EnderC = Range(Selection, Selection.End(xlDown)).Offset(0
2).Address
Debug.Print EnderC
EnderD = Range(Selection, Selection.End(xlDown)).Offset(0
3).Address
Debug.Print EnderD
EnderE = Range(Selection, Selection.End(xlDown)).Offset(0
4).Address
Debug.Print EnderE
Range(EnderE).Formula = _
"=IF(A7=A6,"""",SUMIF((" & EnderA & "),A7,(" & EnderC & "))"
"-SUMIF((" & EnderA & "),A7,(" & EnderD & ")))"
Range("A7").Select
Range(Selection, Selection.End(xlDown)).Offset(0, 4).Copy
Range(Selection, Selection.End(xlDown)).Offset(0, 4).PasteSpecia
xlPasteValues
With Selection
.HorizontalAlignment = xlRight
.Style = "Comma"
.Font.ColorIndex = 5
.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
End With
Columns("C:D").Select
Selection.Style = "Comma"
Range("A1").Select
Application.CutCopyMode = Fals

--
LeeBoWad
-----------------------------------------------------------------------
LeeBoWadd's Profile: http://www.excelforum.com/member.php...fo&userid=1655
View this thread: http://www.excelforum.com/showthread.php?threadid=31409

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
sumif for multi conditions. i.e sumif(A1:A10,"Jon" and B1:B10,"A" Harry Seymour Excel Worksheet Functions 9 June 12th 07 10:47 PM
SUMIF help! Xenos Excel Worksheet Functions 4 September 25th 05 03:25 PM
Embedding a Sumif in a sumif C.Pflugrath Excel Worksheet Functions 5 August 31st 05 07:31 PM
nested sumif or sumif with two criteria dshigley Excel Worksheet Functions 5 April 5th 05 03:34 AM
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function Oscar Excel Worksheet Functions 2 January 11th 05 11:01 PM


All times are GMT +1. The time now is 07:57 AM.

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

About Us

"It's about Microsoft Excel"