Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default how to check first 5 characters of a cell & then sum

Hi,

I'm looking for a way to check the first 5 characters of a cell for a
certain value and if it equals that value to sum the value of another
cell e.g.

Column A, B,
ght991xyz, 10
ght887fht, 100
ght991xyz, 50
ght887fht, 7

So in the example above I'd want to check all rows where column A
starts with ght991 and then sums the value of column B. So the result
of the above would be 60 (50+10).. Not that column A will always
contain digits after the first five, but only the first 5 will match.

Any help would be greatly appreciated.

Best Regards
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default how to check first 5 characters of a cell & then sum

On 20 Sty, 12:52, jonny wrote:
Hi,

I'm looking for a way to check the first 5 characters of a cell for a
certain value and if it equals that value to sum the value of another
cell e.g.

Column A, B,
ght991xyz, 10
ght887fht, 100
ght991xyz, 50
ght887fht, 7

So in the example above I'd want to check all rows where column A
starts with ght991 and then sums the value of column B. *So the result
of the above would be 60 (50+10).. Not that column A will always
contain digits after the first five, but only the first 5 will match.

Any help would be greatly appreciated.

Best Regards


The easisest thing that comes to my mind:

Make a column C, put this formula in it:

=IF((MID(A2;1;6)="ght991");B2;0)

It displays the column B number, if the first 6 chars of column A are
ght991, otherwise zero. Then you just have to sum all of column C and
you get the result.

Regards
lolo
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default how to check first 5 characters of a cell & then sum

Try

=SUMPRODUCT(--(LEFT(A1:A19,6)="ght991"),(B1:B19))

Mike

"jonny" wrote:

Hi,

I'm looking for a way to check the first 5 characters of a cell for a
certain value and if it equals that value to sum the value of another
cell e.g.

Column A, B,
ght991xyz, 10
ght887fht, 100
ght991xyz, 50
ght887fht, 7

So in the example above I'd want to check all rows where column A
starts with ght991 and then sums the value of column B. So the result
of the above would be 60 (50+10).. Not that column A will always
contain digits after the first five, but only the first 5 will match.

Any help would be greatly appreciated.

Best Regards

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default how to check first 5 characters of a cell & then sum

Hi,

Forgot to mention that ght991 is 6 characters not 5

Mike

"Mike H" wrote:

Try

=SUMPRODUCT(--(LEFT(A1:A19,6)="ght991"),(B1:B19))

Mike

"jonny" wrote:

Hi,

I'm looking for a way to check the first 5 characters of a cell for a
certain value and if it equals that value to sum the value of another
cell e.g.

Column A, B,
ght991xyz, 10
ght887fht, 100
ght991xyz, 50
ght887fht, 7

So in the example above I'd want to check all rows where column A
starts with ght991 and then sums the value of column B. So the result
of the above would be 60 (50+10).. Not that column A will always
contain digits after the first five, but only the first 5 will match.

Any help would be greatly appreciated.

Best Regards

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default how to check first 5 characters of a cell & then sum

On Tue, 20 Jan 2009 03:52:22 -0800 (PST), jonny wrote:

Hi,

I'm looking for a way to check the first 5 characters of a cell for a
certain value and if it equals that value to sum the value of another
cell e.g.

Column A, B,
ght991xyz, 10
ght887fht, 100
ght991xyz, 50
ght887fht, 7

So in the example above I'd want to check all rows where column A
starts with ght991 and then sums the value of column B. So the result
of the above would be 60 (50+10).. Not that column A will always
contain digits after the first five, but only the first 5 will match.

Any help would be greatly appreciated.

Best Regards


=SUMPRODUCT((LEFT(A1:A4,6)="ght991")*(B1:B4))

Note that if you are going to check for the presence of "ght991" you will need
to check the first *SIX* characters, and not just FIVE.
--ron


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default how to check first 5 characters of a cell & then sum

On 20 Jan, 12:44, Ron Rosenfeld wrote:
On Tue, 20 Jan 2009 03:52:22 -0800 (PST), jonny wrote:
Hi,


I'm looking for a way to check the first 5 characters of a cell for a
certain value and if it equals that value to sum the value of another
cell e.g.


Column A, B,
ght991xyz, 10
ght887fht, 100
ght991xyz, 50
ght887fht, 7


So in the example above I'd want to check all rows where column A
starts with ght991 and then sums the value of column B. *So the result
of the above would be 60 (50+10).. Not that column A will always
contain digits after the first five, but only the first 5 will match.


Any help would be greatly appreciated.


Best Regards


=SUMPRODUCT((LEFT(A1:A4,6)="ght991")*(B1:B4))

Note that if you are going to check for the presence of "ght991" you will need
to check the first *SIX* characters, and not just FIVE.
--ron- Hide quoted text -

- Show quoted text -


hi everyone,

thanks for your help with this.. The solution works a treat!!

By the way you all passed my test, it was indeed 6 characters and not
5! haha..

Thanks again,

Jon
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
Cannot check the check mark box in cell ac Excel Worksheet Functions 1 February 15th 08 10:24 PM
Characters in cell Iceotope Excel Discussion (Misc queries) 1 August 15th 07 04:08 PM
Check if Conditional Format is True or False / Check cell Color Kevin McCartney Excel Worksheet Functions 5 June 29th 07 11:12 AM
Transfer specific characters from cell to another cell. Willing to learn New Users to Excel 3 June 17th 07 02:14 AM
Check for Alpha characters TimE Excel Discussion (Misc queries) 4 November 10th 05 12:31 AM


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