Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Capture date for =MAX(a1:a250) formula

My spreadsheet has a date column and an amount column. What I want to do is
get the date for the maximum in the amountcolumn.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Capture date for =MAX(a1:a250) formula

With the dates in column A and the amounts in column B, you can use a formula
like:

=index(a:a,match(max(b:b),b:b,0))

In code:

dim res as variant
dim myRng as range

with activesheet
set myrng = .range("b:b")
end with

with application
if .count(myrng) = 0 then
msgbox "No Numbers!"
else
res = .match(.max(myrng),myrng,0)
end if
end with

if iserror(res) then
'this shouldn't ever happen!
else
msgbox myrng.cells(1,1).offset(res-1,-1).value
end if


Rick I wrote:

My spreadsheet has a date column and an amount column. What I want to do is
get the date for the maximum in the amountcolumn.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Capture date for =MAX(a1:a250) formula

Just a rearrangement of code to stop some potential errors:

dim res as variant
dim myRng as range

with activesheet
set myrng = .range("b:b")
end with

with application
if .count(myrng) = 0 then
msgbox "No Numbers!"
else
res = .match(.max(myrng),myrng,0)
if iserror(res) then
'this shouldn't ever happen!
else
msgbox myrng.cells(1,1).offset(res-1,-1).value
end if
end if
end with

Dave Peterson wrote:

With the dates in column A and the amounts in column B, you can use a formula
like:

=index(a:a,match(max(b:b),b:b,0))

In code:

dim res as variant
dim myRng as range

with activesheet
set myrng = .range("b:b")
end with

with application
if .count(myrng) = 0 then
msgbox "No Numbers!"
else
res = .match(.max(myrng),myrng,0)
end if
end with

if iserror(res) then
'this shouldn't ever happen!
else
msgbox myrng.cells(1,1).offset(res-1,-1).value
end if

Rick I wrote:

My spreadsheet has a date column and an amount column. What I want to do is
get the date for the maximum in the amountcolumn.


--

Dave Peterson


--

Dave Peterson
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
How do I capture a date? Capture a variable date & use with text Excel Discussion (Misc queries) 3 November 27th 08 02:40 AM
Excel screen capture to capture cells and row and column headings jayray Excel Discussion (Misc queries) 5 November 2nd 07 11:01 PM
want to capture date elegantpartner Excel Discussion (Misc queries) 1 January 9th 06 04:20 AM
Formula to capture data on a date and preserve it Jeff Excel Worksheet Functions 0 October 11th 05 11:18 PM
How do I capture the Modified date in a cell? rcg[_2_] Excel Programming 2 March 9th 05 05:24 PM


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