ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Lookup-value in HLOOKUP? (https://www.excelbanter.com/excel-worksheet-functions/210413-lookup-value-hlookup.html)

ChrisP

Lookup-value in HLOOKUP?
 
It seems you can't use a formula (eg "0") as the lookup value in VLOOKUP or
HLOOKUP. Is there a way around this? I have month by month sales data for
a few thousand items for 36 months and I am trying to establish how many
months ago was the last sales activity.

smartin

Lookup-value in HLOOKUP?
 
Chrisp wrote:
It seems you can't use a formula (eg "0") as the lookup value in VLOOKUP or
HLOOKUP. Is there a way around this? I have month by month sales data for
a few thousand items for 36 months and I am trying to establish how many
months ago was the last sales activity.


Hi Chrisp, Show us how you have your data organized.

ChrisP

Lookup-value in HLOOKUP?
 
Hi,

I have table of 36 months of historical data
-Column headings are month/year in order (oldest to newest left to right)
-Row headings are product codes
-Data is the quantity sold for each product each month

With a few thousand products, my challenge is to find a quick way of
calculating for each product how many months have elapsed since the last sale
- ie how many zeros, if any, at the right hand end of each row. This is to
identify products which may be obsolete.

I thought that using HLOOKUP might have some potential, but I am beginning
to think that this may have to be a macro solution.

Would certainly appreciate any ideas you may have.

Many thanks

Chris P


"smartin" wrote:

Chrisp wrote:
It seems you can't use a formula (eg "0") as the lookup value in VLOOKUP or
HLOOKUP. Is there a way around this? I have month by month sales data for
a few thousand items for 36 months and I am trying to establish how many
months ago was the last sales activity.


Hi Chrisp, Show us how you have your data organized.


smartin

Lookup-value in HLOOKUP?
 
Hi Chrisp,

With 36 months in columns B:AK starting in row 2, the following array
formula* placed in a convenient column to the right of your data will
return the right-most column number with a non-zero value (*array
formula -- commit with Ctrl+Shift+Enter):

=MAX(--($B2:$AK2<0)*COLUMN($B2:$AK2))

a quick modification tells you how many right-trailing zeros you have on
each row (again, an array formula):

=37-MAX(--($B2:$AK2<0)*COLUMN($B2:$AK2))

Hope this helps!

Chrisp wrote:
Hi,

I have table of 36 months of historical data
-Column headings are month/year in order (oldest to newest left to right)
-Row headings are product codes
-Data is the quantity sold for each product each month

With a few thousand products, my challenge is to find a quick way of
calculating for each product how many months have elapsed since the last sale
- ie how many zeros, if any, at the right hand end of each row. This is to
identify products which may be obsolete.

I thought that using HLOOKUP might have some potential, but I am beginning
to think that this may have to be a macro solution.

Would certainly appreciate any ideas you may have.

Many thanks

Chris P


"smartin" wrote:

Chrisp wrote:
It seems you can't use a formula (eg "0") as the lookup value in VLOOKUP or
HLOOKUP. Is there a way around this? I have month by month sales data for
a few thousand items for 36 months and I am trying to establish how many
months ago was the last sales activity.

Hi Chrisp, Show us how you have your data organized.


ChrisP

Lookup-value in HLOOKUP?
 
Hi smartin,

My apologies for the delay in replying - had hardware problems.

Your proposal is as effective as it is neat. I had put together a very
clunky solution that involved creating another 36 columns that could be
hidden later, each containing a formula to count blank columns. Your idea is
infinitely better.

Many thanks again,

ChrisP

"smartin" wrote:

Hi Chrisp,

With 36 months in columns B:AK starting in row 2, the following array
formula* placed in a convenient column to the right of your data will
return the right-most column number with a non-zero value (*array
formula -- commit with Ctrl+Shift+Enter):

=MAX(--($B2:$AK2<0)*COLUMN($B2:$AK2))

a quick modification tells you how many right-trailing zeros you have on
each row (again, an array formula):

=37-MAX(--($B2:$AK2<0)*COLUMN($B2:$AK2))

Hope this helps!

Chrisp wrote:
Hi,

I have table of 36 months of historical data
-Column headings are month/year in order (oldest to newest left to right)
-Row headings are product codes
-Data is the quantity sold for each product each month

With a few thousand products, my challenge is to find a quick way of
calculating for each product how many months have elapsed since the last sale
- ie how many zeros, if any, at the right hand end of each row. This is to
identify products which may be obsolete.

I thought that using HLOOKUP might have some potential, but I am beginning
to think that this may have to be a macro solution.

Would certainly appreciate any ideas you may have.

Many thanks

Chris P


"smartin" wrote:

Chrisp wrote:
It seems you can't use a formula (eg "0") as the lookup value in VLOOKUP or
HLOOKUP. Is there a way around this? I have month by month sales data for
a few thousand items for 36 months and I am trying to establish how many
months ago was the last sales activity.
Hi Chrisp, Show us how you have your data organized.




All times are GMT +1. The time now is 09:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com