Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default working with data

I'm using excel 2002. I get a report from a database with the format: "1x
#02-0001/56 ProductA 3x #04-0003/87 ProductB 1x 02-0009/65 ProductC" in one
cell. Where the number before x is the quantity sold, the rest are product
numbers and descriptions. What would I use to answer the following
questions... find all ProductB and return the Quantity (in this case,
quantity is 3). The product may appear in any order and any quantity in the
cell. Thanks for your help.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default working with data

First, I would use Data/Text To Columns using space as the delimiter to get
the data into separate cells. This would put your sample data in cells A1:I1
(make sure there is nothing in B1:I1 when you do this as it will overwrite
existing data in these cells).

Then in J1 (assuming the quantity will always appear 2 columns before the
product description):

=--SUBSTITUTE(INDEX(A1:I1,MATCH("ProductB",A1:I1,0)-2),"x","")

If it is possible Product B may not appear and you want to avoid #N/A errors:

=IF(ISNUMBER(MATCH("ProductB",A1:I1,0)),--SUBSTITUTE(INDEX(A1:I1,MATCH("ProductB",A1:I1,0)-2),"x",""),"")

Then copy down column J.

"Joikochan" wrote:

I'm using excel 2002. I get a report from a database with the format: "1x
#02-0001/56 ProductA 3x #04-0003/87 ProductB 1x 02-0009/65 ProductC" in one
cell. Where the number before x is the quantity sold, the rest are product
numbers and descriptions. What would I use to answer the following
questions... find all ProductB and return the Quantity (in this case,
quantity is 3). The product may appear in any order and any quantity in the
cell. Thanks for your help.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default working with data

One venture ..

Assuming source data as posted in A1 down,
with products listed in B1 down, ie in B1 is for eg: ProductB

Try in C1:
=LEFT(MID(A1,SEARCH(B1,A1)+LEN(B1),5),SEARCH("x",M ID(A1,SEARCH(B1,A1)+LEN(B1),5))-1)+0
Copy down as required.

For the sample source data as posted placed in A1
if you have in B1: ProductB,
you'd get in C1: 1

And if you have in B1: ProductA,
you'd get in C1: 3
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Joikochan" wrote:
I'm using excel 2002. I get a report from a database with the format: "1x
#02-0001/56 ProductA 3x #04-0003/87 ProductB 1x 02-0009/65 ProductC" in one
cell. Where the number before x is the quantity sold, the rest are product
numbers and descriptions. What would I use to answer the following
questions... find all ProductB and return the Quantity (in this case,
quantity is 3). The product may appear in any order and any quantity in the
cell. Thanks for your help.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default working with data

The NG wrapped the OP's example a little funny - looks like the quantity
appears before the Product description, so for ProductB, OP wants 3 and for
ProductA it would be 1 and ProductC would also be 1 (although I assumed the
OP is only looking for ProductB, but finding A and C are the most likely
follow-up questions <g).



"Max" wrote:

One venture ..

Assuming source data as posted in A1 down,
with products listed in B1 down, ie in B1 is for eg: ProductB

Try in C1:
=LEFT(MID(A1,SEARCH(B1,A1)+LEN(B1),5),SEARCH("x",M ID(A1,SEARCH(B1,A1)+LEN(B1),5))-1)+0
Copy down as required.

For the sample source data as posted placed in A1
if you have in B1: ProductB,
you'd get in C1: 1

And if you have in B1: ProductA,
you'd get in C1: 3
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Joikochan" wrote:
I'm using excel 2002. I get a report from a database with the format: "1x
#02-0001/56 ProductA 3x #04-0003/87 ProductB 1x 02-0009/65 ProductC" in one
cell. Where the number before x is the quantity sold, the rest are product
numbers and descriptions. What would I use to answer the following
questions... find all ProductB and return the Quantity (in this case,
quantity is 3). The product may appear in any order and any quantity in the
cell. Thanks for your help.

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default working with data

Thanks

"JMB" wrote:

The NG wrapped the OP's example a little funny - looks like the quantity
appears before the Product description, so for ProductB, OP wants 3 and for
ProductA it would be 1 and ProductC would also be 1 (although I assumed the
OP is only looking for ProductB, but finding A and C are the most likely
follow-up questions <g).



"Max" wrote:

One venture ..

Assuming source data as posted in A1 down,
with products listed in B1 down, ie in B1 is for eg: ProductB

Try in C1:
=LEFT(MID(A1,SEARCH(B1,A1)+LEN(B1),5),SEARCH("x",M ID(A1,SEARCH(B1,A1)+LEN(B1),5))-1)+0
Copy down as required.

For the sample source data as posted placed in A1
if you have in B1: ProductB,
you'd get in C1: 1

And if you have in B1: ProductA,
you'd get in C1: 3
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Joikochan" wrote:
I'm using excel 2002. I get a report from a database with the format: "1x
#02-0001/56 ProductA 3x #04-0003/87 ProductB 1x 02-0009/65 ProductC" in one
cell. Where the number before x is the quantity sold, the rest are product
numbers and descriptions. What would I use to answer the following
questions... find all ProductB and return the Quantity (in this case,
quantity is 3). The product may appear in any order and any quantity in the
cell. Thanks for your help.



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default working with data

Ahh, think you're right there <g. What was suggested presumed the "x" is
after the "Product". It won't work if the "x" is before the "Product". I
don't have an alternative to suggest here. Cheers.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"JMB" wrote in message
...
The NG wrapped the OP's example a little funny - looks like the quantity
appears before the Product description, so for ProductB, OP wants 3 and
for
ProductA it would be 1 and ProductC would also be 1 (although I assumed
the
OP is only looking for ProductB, but finding A and C are the most likely
follow-up questions <g).



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default working with data

That's what I thought at first, too. Just for the sake of academics (and I'm
trying to avoid doing my chores), if B1=ProductB this appeared to work (no
errorhandling)

C1 (CSE) =MATCH(SEARCH(B1,A1)-2,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="
",ROW(INDIRECT("1:"&LEN(A1)))))

D1 (CSE) =IF(ISNUMBER(MATCH(C1-1,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="
",ROW(INDIRECT("1:"&LEN(A1)))))),MATCH(C1-1,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)=" ",ROW(INDIRECT("1:"&LEN(A1))))),1)

E1 =--SUBSTITUTE(MID(A1,D1,C1-D1),"x","")

But that's about as good as I could get it using only a formula approach.
Have a good day/evening (whichever is appropriate <g).



"Max" wrote:

Ahh, think you're right there <g. What was suggested presumed the "x" is
after the "Product". It won't work if the "x" is before the "Product". I
don't have an alternative to suggest here. Cheers.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"JMB" wrote in message
...
The NG wrapped the OP's example a little funny - looks like the quantity
appears before the Product description, so for ProductB, OP wants 3 and
for
ProductA it would be 1 and ProductC would also be 1 (although I assumed
the
OP is only looking for ProductB, but finding A and C are the most likely
follow-up questions <g).




  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default working with data

Thought it was a marvellous formulas-only rendition, JMB!
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"JMB" wrote in message
...
That's what I thought at first, too. Just for the sake of academics (and
I'm
trying to avoid doing my chores), if B1=ProductB this appeared to work (no
errorhandling)

C1 (CSE) =MATCH(SEARCH(B1,A1)-2,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="
",ROW(INDIRECT("1:"&LEN(A1)))))

D1 (CSE)
=IF(ISNUMBER(MATCH(C1-1,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="
",ROW(INDIRECT("1:"&LEN(A1)))))),MATCH(C1-1,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="
",ROW(INDIRECT("1:"&LEN(A1))))),1)

E1 =--SUBSTITUTE(MID(A1,D1,C1-D1),"x","")

But that's about as good as I could get it using only a formula approach.
Have a good day/evening (whichever is appropriate <g).



  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default working with data

Thanks Max!

"Max" wrote:

Thought it was a marvellous formulas-only rendition, JMB!
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"JMB" wrote in message
...
That's what I thought at first, too. Just for the sake of academics (and
I'm
trying to avoid doing my chores), if B1=ProductB this appeared to work (no
errorhandling)

C1 (CSE) =MATCH(SEARCH(B1,A1)-2,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="
",ROW(INDIRECT("1:"&LEN(A1)))))

D1 (CSE)
=IF(ISNUMBER(MATCH(C1-1,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="
",ROW(INDIRECT("1:"&LEN(A1)))))),MATCH(C1-1,IF(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="
",ROW(INDIRECT("1:"&LEN(A1))))),1)

E1 =--SUBSTITUTE(MID(A1,D1,C1-D1),"x","")

But that's about as good as I could get it using only a formula approach.
Have a good day/evening (whichever is appropriate <g).




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
Data Validation not working!! Please help!!!! [email protected] Excel Discussion (Misc queries) 13 April 19th 07 12:08 PM
Working with data from two worksheets Nithya Excel Worksheet Functions 1 November 20th 06 05:42 PM
Data Sort NOT working... Bob Barnes Excel Discussion (Misc queries) 1 June 20th 06 11:00 PM
Working with data? FF Excel Worksheet Functions 4 November 14th 05 02:35 AM
working with data between worksheets steve Excel Discussion (Misc queries) 1 August 10th 05 01:16 PM


All times are GMT +1. The time now is 04:18 AM.

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"