Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 76
Default If column = value sum another column and place result in cell

I've edited the following code based on some of the ideas that I've
seen on this group. Ultimately I would like to evaluate two colums
for specific values and if those values are true then sum two other
columns. So basically I have two totals as a result. For testing how
to do this I'm working with one column for eval and one column for
total as shown below, however it's providing me a #NAME? in cel J1

'We use the ActiveSheet but you can replace this with
With ActiveSheet

'define varibles for data
Dim ncgwsuactuals As Long
Dim ncgwsuallocated As Long
ncgwsuactuals = 0
ncgwsuallocated = 0
'We select the sheet so we can change the window view
.Select

'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False

'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row + 1
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1

If .Cells(Lrow, "D").Value = "146268" Or _
.Cells(Lrow, "D").Value = "146269" Or _
.Cells(Lrow, "D").Value = "146270" Or _
.Cells(Lrow, "D").Value = "133957" Then .Cells(Lrow,
"G").Value = ncgwsuactuals + ncgwsuactuals
Next Lrow

With Range("J1")
.FormulaArray = "=ncgwsuactuals"
.Calculate
.Value = .Value
End With

End With
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 76
Default If column = value sum another column and place result in cell

I think this would be a simpler solution:

=SUMPRODUCT(--('SOURCE DATA'!D2:D4000="133957")+('SOURCE DATA'!
D2:D4000="146268"),'SOURCE DATA'!G2:G4000)

however I'm not getting my total of column G based on the two values
sepecified in range D2:D4000
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
add numbers in a column and transfer result to another column planecents Excel Worksheet Functions 3 March 2nd 07 06:05 PM
Lock column/row in place pelachrum Excel Discussion (Misc queries) 1 July 24th 06 07:30 AM
how to display the column or cell the MIN() result came from? Fadi Excel Worksheet Functions 4 March 2nd 06 09:17 PM
read a column of names and place a number in the next cell Judy Hallinan Excel Discussion (Misc queries) 1 December 7th 05 11:48 PM
How do I convert the result of LARGE to the cell (or column) refe. Liam Judd Excel Worksheet Functions 1 November 17th 04 08:44 AM


All times are GMT +1. The time now is 12:41 PM.

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"