Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Sum all search results?

What's the easiest way to search through Column A for a number (multiple
instances), and summing up all the numbers in Column B on the same row as the
numebrs found in Column A?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Sum all search results?

=SUMIF(A:A,33,B:B)

if you are searching for the number 33, for example.
__________________________________________________ _____________________

"J@Y" wrote in message
...
What's the easiest way to search through Column A for a number (multiple
instances), and summing up all the numbers in Column B on the same row as
the
numebrs found in Column A?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Sum all search results?

Hi

Not entirely sure what you are asking for but i have decided to go
with for each of the used cells in column A if the cell contains a
number then take the number in column B for that row add it to a
running total that will show at the end???
The code below will do just that though if it's not what you are
looking for it should at least give you somewhere to start.

Option Explicit
Dim MyCell, MyRng As Range
Dim SumTotal As Integer
Dim LstRow As Integer

Private Sub CommandButton1_Click()

SumTotal = 0

LstRow = [A65535].End(xlUp).Row

Set MyRng = Range("A1:A" & LstRow)

For Each MyCell In MyRng

If IsNumeric(MyCell.Value) = True Then

SumTotal = SumTotal + MyCell.Offset(0, 1).Value

End If

Next MyCell

MsgBox SumTotal

End Sub

hope this is of some help

S


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sum all search results?

I would use
=sumif(a:a,789,b:b)
in a cell in a worksheet

In code, I'd use:

with worksheets("sheet1")
msgbox application.sumif(.range("a:a"),789,.range("b:b"))
end with

J@Y wrote:

What's the easiest way to search through Column A for a number (multiple
instances), and summing up all the numbers in Column B on the same row as the
numebrs found in Column A?


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Sum all search results?



Vasant's approach can also be implemented in VBA if you must do this as part
of a macro.

With Worksheets("Sheet1")
Tot = Application.Countif(.Columns(1),.Range("A1"),.Colu mns(2))
End with

where cell A1 contains the number you are looking for, but that could be in
any cell. For example Z22

With Worksheets("Sheet1")
Tot = Application.Countif(.Columns(1),.Range("Z22"),.Col umns(2))
End with

or just in a variable

num = 32
With Worksheets("Sheet1")
Tot = Application.Countif(.Columns(1),num,.Columns(2))
End with

--
Regards,
Tom Ogilvy



"Incidental" wrote:

Hi

Not entirely sure what you are asking for but i have decided to go
with for each of the used cells in column A if the cell contains a
number then take the number in column B for that row add it to a
running total that will show at the end???
The code below will do just that though if it's not what you are
looking for it should at least give you somewhere to start.

Option Explicit
Dim MyCell, MyRng As Range
Dim SumTotal As Integer
Dim LstRow As Integer

Private Sub CommandButton1_Click()

SumTotal = 0

LstRow = [A65535].End(xlUp).Row

Set MyRng = Range("A1:A" & LstRow)

For Each MyCell In MyRng

If IsNumeric(MyCell.Value) = True Then

SumTotal = SumTotal + MyCell.Offset(0, 1).Value

End If

Next MyCell

MsgBox SumTotal

End Sub

hope this is of some help

S





  #6   Report Post  
Posted to microsoft.public.excel.programming
V V is offline
external usenet poster
 
Posts: 26
Default Sum all search results?

hi
I'd just like to confuse things further, I have an accounts table showing
income. I would like to total the results of two columns
eg. if my income is due to "membership" then I would like to total the
"membership" income, which is shown in columns D, E and F (voucher, cheque,
and cash)
I tried the formula below but it only seems to total d3:d21 even tho i've
stated d3:f21

=SUMIF(B3:B21,"membership",D3:F21)

The only way I can get it to work is by using the following formula

=SUM(SUMIF(B3:B21,"membership",D3:D21),SUMIF(B3:B2 1,"membership",E3:E21),SUMIF(B3:B21,"membership",F 3:F21))

which as you can see is very long, is there a shorter, quicker formula?



"Vasant Nanavati" wrote:

=SUMIF(A:A,33,B:B)

if you are searching for the number 33, for example.
__________________________________________________ _____________________

"J@Y" wrote in message
...
What's the easiest way to search through Column A for a number (multiple
instances), and summing up all the numbers in Column B on the same row as
the
numebrs found in Column A?




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
Help! I can't get any search results Acanesfan Excel Discussion (Misc queries) 4 October 10th 08 10:16 PM
Search Results Loadmaster Excel Discussion (Misc queries) 0 July 29th 08 01:52 PM
multiple results from search / how to? ORLANDO V[_2_] Excel Discussion (Misc queries) 0 January 29th 08 08:12 PM
I cant do a search on this forum. Everytime I search, it comes up with zero results viswanthank Excel Programming 3 June 10th 05 09:15 AM
multiple results search ruchir Excel Programming 8 March 5th 04 04:06 PM


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