Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Finding the Max Date In Series

Hello,

I have a series of serial numbers (converted to text), dates and
amounts in column format. The number of serial numbers changes
depending on the date sold. The amount it sold for also changes. for
example

001 1-3-09 $300
001 1-5-07 $250
001 2-3-02 $550
002 4-3-01 $600
002 5-9-05 $300
003 6-9-07 $200

There are numerous serial numbers that repeat numerous times (about
5000 rows of code)

I would like to write a formula that finds the maximum date for the
001 for example and then returns the dollar figure in that row. Is
this a formula or do I need VBA?

Thank you for your time

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Finding the Max Date In Series

Hi,

You can do it with a formula

=VLOOKUP(MAX(IF(A1:A12=1,B1:B12)),B1:C12,2,FALSE)

This is an array formula which must be entered with CTRL+Shift+Enter and NOT
'just enter. If you do it correctly then Excel will put curly brackets around
'the formula{}. You can't type these yourself. If you Edit the ranges
'then you must re-enter as An array

Mike

"cardan" wrote:

Hello,

I have a series of serial numbers (converted to text), dates and
amounts in column format. The number of serial numbers changes
depending on the date sold. The amount it sold for also changes. for
example

001 1-3-09 $300
001 1-5-07 $250
001 2-3-02 $550
002 4-3-01 $600
002 5-9-05 $300
003 6-9-07 $200

There are numerous serial numbers that repeat numerous times (about
5000 rows of code)

I would like to write a formula that finds the maximum date for the
001 for example and then returns the dollar figure in that row. Is
this a formula or do I need VBA?

Thank you for your time


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Finding the Max Date In Series

OOPS,

I missed your 'numbers' are text

=VLOOKUP(MAX(IF(A1:A12="001",B1:B12)),B1:C12,2,FAL SE)

Don't forget the array instructions

Mike

"Mike H" wrote:

Hi,

You can do it with a formula

=VLOOKUP(MAX(IF(A1:A12=1,B1:B12)),B1:C12,2,FALSE)

This is an array formula which must be entered with CTRL+Shift+Enter and NOT
'just enter. If you do it correctly then Excel will put curly brackets around
'the formula{}. You can't type these yourself. If you Edit the ranges
'then you must re-enter as An array

Mike

"cardan" wrote:

Hello,

I have a series of serial numbers (converted to text), dates and
amounts in column format. The number of serial numbers changes
depending on the date sold. The amount it sold for also changes. for
example

001 1-3-09 $300
001 1-5-07 $250
001 2-3-02 $550
002 4-3-01 $600
002 5-9-05 $300
003 6-9-07 $200

There are numerous serial numbers that repeat numerous times (about
5000 rows of code)

I would like to write a formula that finds the maximum date for the
001 for example and then returns the dollar figure in that row. Is
this a formula or do I need VBA?

Thank you for your time


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Finding the Max Date In Series

On Feb 19, 10:04*am, Mike H wrote:
OOPS,

I missed your 'numbers' are text

=VLOOKUP(MAX(IF(A1:A12="001",B1:B12)),B1:C12,2,FAL SE)

Don't forget the array instructions

Mike

"Mike H" wrote:
Hi,


You can do it with a formula


=VLOOKUP(MAX(IF(A1:A12=1,B1:B12)),B1:C12,2,FALSE)


This is an array formula which must be entered with CTRL+Shift+Enter and NOT
'just enter. If you do it correctly then Excel will put curly brackets around
'the formula{}. You can't type these yourself. If you Edit the ranges
'then you must re-enter as An array


Mike


"cardan" wrote:


Hello,


I have a series of serial numbers (converted to text), dates and
amounts in column format. The number of serial numbers changes
depending on the date sold. The amount it sold for also changes. for
example


001 * 1-3-09 * $300
001 * 1-5-07 * $250
001 * 2-3-02 * $550
002 * *4-3-01 *$600
002 * 5-9-05 * *$300
003 * 6-9-07 * *$200


There are numerous serial numbers that repeat numerous times (about
5000 rows of code)


I would like to write a formula that finds the maximum date for the
001 for example and then returns the dollar figure in that row. *Is
this a formula or do I need VBA?


Thank you for *your time


Hi Mike, Thank you for your response. I am getting a number but it is
not the correct one. Upon evaluating the formula, it seems to be
pulling the correct date, but there are multiple dates that are the
same so I think it is pulling the amount from the first date that
equals the max date for "001", regardless of the "001" criteria. Any
way to correct?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Finding the Max Date In Series

Hi,

I'm sure this can be done with a formula but I'm stumped so heres a
function. Alt +F11 to open VB editor. Right click 'ThisWorkbook' and insert
module and paste the code in

Call with

=Bestrow(A1:A100,"001")

or use a cell reference for the text value

=bestrow(a1:a100,D1)

Note it will work anywhere in the sheet but always uses the 2 columns to the
right of the range you specify in the function call.

Function bestrow(rng As Range, lval As String)
For Each c In rng
If c.Value = lval Then
founddate = c.Offset(, 1).Value
If founddate = bestdate Then
bestrow = c.Offset(, 2).Value
End If
End If
Next
End Function

Mike


"cardan" wrote:

On Feb 19, 10:04 am, Mike H wrote:
OOPS,

I missed your 'numbers' are text

=VLOOKUP(MAX(IF(A1:A12="001",B1:B12)),B1:C12,2,FAL SE)

Don't forget the array instructions

Mike

"Mike H" wrote:
Hi,


You can do it with a formula


=VLOOKUP(MAX(IF(A1:A12=1,B1:B12)),B1:C12,2,FALSE)


This is an array formula which must be entered with CTRL+Shift+Enter and NOT
'just enter. If you do it correctly then Excel will put curly brackets around
'the formula{}. You can't type these yourself. If you Edit the ranges
'then you must re-enter as An array


Mike


"cardan" wrote:


Hello,


I have a series of serial numbers (converted to text), dates and
amounts in column format. The number of serial numbers changes
depending on the date sold. The amount it sold for also changes. for
example


001 1-3-09 $300
001 1-5-07 $250
001 2-3-02 $550
002 4-3-01 $600
002 5-9-05 $300
003 6-9-07 $200


There are numerous serial numbers that repeat numerous times (about
5000 rows of code)


I would like to write a formula that finds the maximum date for the
001 for example and then returns the dollar figure in that row. Is
this a formula or do I need VBA?


Thank you for your time


Hi Mike, Thank you for your response. I am getting a number but it is
not the correct one. Upon evaluating the formula, it seems to be
pulling the correct date, but there are multiple dates that are the
same so I think it is pulling the amount from the first date that
equals the max date for "001", regardless of the "001" criteria. Any
way to correct?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Finding the Max Date In Series

Sorry,

pasted a debug version, try this one

Function bestrow(rng As Range, lval As String)
For Each c In rng
If c.Value = lval Then
founddate = c.Offset(, 1).Value
If founddate = bestdate Then
bestdate = founddate
bestrow = c.Offset(, 2).Value
End If
End If
Next
End Function

Mike

"Mike H" wrote:

Hi,

I'm sure this can be done with a formula but I'm stumped so heres a
function. Alt +F11 to open VB editor. Right click 'ThisWorkbook' and insert
module and paste the code in

Call with

=Bestrow(A1:A100,"001")

or use a cell reference for the text value

=bestrow(a1:a100,D1)

Note it will work anywhere in the sheet but always uses the 2 columns to the
right of the range you specify in the function call.

Function bestrow(rng As Range, lval As String)
For Each c In rng
If c.Value = lval Then
founddate = c.Offset(, 1).Value
If founddate = bestdate Then
bestrow = c.Offset(, 2).Value
End If
End If
Next
End Function

Mike


"cardan" wrote:

On Feb 19, 10:04 am, Mike H wrote:
OOPS,

I missed your 'numbers' are text

=VLOOKUP(MAX(IF(A1:A12="001",B1:B12)),B1:C12,2,FAL SE)

Don't forget the array instructions

Mike

"Mike H" wrote:
Hi,

You can do it with a formula

=VLOOKUP(MAX(IF(A1:A12=1,B1:B12)),B1:C12,2,FALSE)

This is an array formula which must be entered with CTRL+Shift+Enter and NOT
'just enter. If you do it correctly then Excel will put curly brackets around
'the formula{}. You can't type these yourself. If you Edit the ranges
'then you must re-enter as An array

Mike

"cardan" wrote:

Hello,

I have a series of serial numbers (converted to text), dates and
amounts in column format. The number of serial numbers changes
depending on the date sold. The amount it sold for also changes. for
example

001 1-3-09 $300
001 1-5-07 $250
001 2-3-02 $550
002 4-3-01 $600
002 5-9-05 $300
003 6-9-07 $200

There are numerous serial numbers that repeat numerous times (about
5000 rows of code)

I would like to write a formula that finds the maximum date for the
001 for example and then returns the dollar figure in that row. Is
this a formula or do I need VBA?

Thank you for your time


Hi Mike, Thank you for your response. I am getting a number but it is
not the correct one. Upon evaluating the formula, it seems to be
pulling the correct date, but there are multiple dates that are the
same so I think it is pulling the amount from the first date that
equals the max date for "001", regardless of the "001" criteria. Any
way to correct?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Finding the Max Date In Series

On Feb 19, 11:47*am, Mike H wrote:
Sorry,

pasted a debug version, try this one

Function bestrow(rng As Range, lval As String)
For Each c In rng
If c.Value = lval Then
* * founddate = c.Offset(, 1).Value
* * * * If founddate = bestdate Then
* * * * * * bestdate = founddate
* * * * * * bestrow = c.Offset(, 2).Value
* * * * End If
End If
Next
End Function

Mike

"Mike H" wrote:
Hi,


I'm sure this can be done with a formula but I'm stumped so heres a
function. Alt +F11 to open VB editor. Right click 'ThisWorkbook' and insert
module and paste the code in


Call with


=Bestrow(A1:A100,"001")


or use a cell reference for the text value


=bestrow(a1:a100,D1)


Note it will work anywhere in the sheet but always uses the 2 columns to the
right of the range you specify in the function call.


Function bestrow(rng As Range, lval As String)
For Each c In rng
If c.Value = lval Then
* * founddate = c.Offset(, 1).Value
* * * * If founddate = bestdate Then
* * * * * * bestrow = c.Offset(, 2).Value
* * * * End If
End If
Next
End Function


Mike


"cardan" wrote:


On Feb 19, 10:04 am, Mike H wrote:
OOPS,


I missed your 'numbers' are text


=VLOOKUP(MAX(IF(A1:A12="001",B1:B12)),B1:C12,2,FAL SE)


Don't forget the array instructions


Mike


"Mike H" wrote:
Hi,


You can do it with a formula


=VLOOKUP(MAX(IF(A1:A12=1,B1:B12)),B1:C12,2,FALSE)


This is an array formula which must be entered with CTRL+Shift+Enter and NOT
'just enter. If you do it correctly then Excel will put curly brackets around
'the formula{}. You can't type these yourself. If you Edit the ranges
'then you must re-enter as An array


Mike


"cardan" wrote:


Hello,


I have a series of serial numbers (converted to text), dates and
amounts in column format. The number of serial numbers changes
depending on the date sold. The amount it sold for also changes.. for
example


001 * 1-3-09 * $300
001 * 1-5-07 * $250
001 * 2-3-02 * $550
002 * *4-3-01 *$600
002 * 5-9-05 * *$300
003 * 6-9-07 * *$200


There are numerous serial numbers that repeat numerous times (about
5000 rows of code)


I would like to write a formula that finds the maximum date for the
001 for example and then returns the dollar figure in that row. *Is
this a formula or do I need VBA?


Thank you for *your time


Hi Mike, Thank you for your response. I am getting a number but it is
not the correct one. Upon evaluating the formula, it seems to be
pulling the correct date, but there are multiple dates that are the
same so I think it is pulling the amount from the first date that
equals the max date for "001", regardless of the "001" criteria. *Any
way to correct?


Thanks Mike, I will give it a shot!
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
Finding next number in a series Iriemon Excel Worksheet Functions 2 May 12th 10 09:11 PM
Finding series index if I know the Series Name Barb Reinhardt Charts and Charting in Excel 2 January 23rd 07 01:01 PM
Finding the last cell in a series Arne Hegefors Excel Programming 1 July 19th 06 02:47 PM
finding chart series low Paul Excel Programming 3 May 23rd 06 01:45 AM
Filling in a Date Series using the Fill | Series menu command Bob C Excel Programming 3 February 1st 05 11:13 PM


All times are GMT +1. The time now is 03:44 AM.

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"