Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default sum values in a col only if value in next col is desired value

add numbers in col A if values in col B = M only
Excel 2003
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default sum values in a col only if value in next col is desired value

"u999rbm" wrote in message
...
add numbers in col A if values in col B = M only
Excel 2003



Hi U,

If a worksheet formula would suit, try:

=SUMIF(B1:B100,"=M",A1:A100)


---
Regards,
Norman




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default sum values in a col only if value in next col is desired value

You can use both worksheet functions or VBA to solve the problem.
First of all, let's see additional worksheet function solutions using array
functions techniques.

For example, if you got a list of numbers in A1:A20, and you got those "M"
in the adjacent column (B).

You can type the array formula:
=SUM(A1:A20*((B1:B20)="M"))

To input an array formula, after typing the formula, hold Ctrl+Shift then
press Enter.

Or, you can use the following "more clever" array formula:
=SUM(A1:A20*(OFFSET(A1:A20,,1)="M"))


Then, let's see the VBA solution.

With the cells in column A selected, run the macro below.

Sub example_macro()
Dim a As Range
Dim cell As Object
Dim answer
Set a = Selection 'can replace this with another range object description

For Each cell In a
If cell.Offset(0, 1).Value = "M" Then
answer = answer + cell.Value
End If
Next

MsgBox answer
End Sub

Regards,
Edwin Tam

http://www.vonixx.com


"u999rbm" wrote:

add numbers in col A if values in col B = M only
Excel 2003

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default sum values in a col only if value in next col is desired value

What is =SUMIF(B1:B10,"M",A1:A10) ?

Good luck.

Ken
Norfolk, Va
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
Vlookup for multiple values and return to one desired value nsd Excel Worksheet Functions 8 September 23rd 08 10:44 PM
IRR desired return izbix Excel Worksheet Functions 3 May 3rd 07 06:47 AM
Returning the desired value if multiple values exist???? njuneardave Excel Worksheet Functions 1 June 21st 06 08:32 PM
Count number of times two columns have desired values Gavin Deveau Excel Discussion (Misc queries) 2 June 16th 06 06:29 PM
Simplicity is Desired natei6 Excel Worksheet Functions 8 April 11th 06 07:10 AM


All times are GMT +1. The time now is 12:57 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"