VBA help - extract Max and Min date from a Range

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,

How to find max date and min date from a Range. data is in text format.

Expected output is in Column D.

Below is a Data with output.

Book6
ABCD
1Date
201/02/18MinDate01/02/18
302/05/18MaxDate08/04/20
403/28/18
508/04/20
605/26/20
706/13/20
Sheet1


Thanks
mg
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
If they are in Text format, enter these formulas as arrays (use "CTRL+SHIFT+ENTER" instead of just enter to enter them; note the squiggly brackets are not really there, they just indicate it is an array formula).

MIN:
Excel Formula:
{=MIN(DATEVALUE(A2:A7))}

MAX:
Excel Formula:
{=MAX(DATEVALUE(A2:A7))}
 
Upvote 0
Hi Joe4,

I tried it, but not working. what if date column is in text and not in text.

I am looking help in vba, so that I want to use it in autofilter , greater than max date etc.



VBA Code:
Sub test()
Dim str As Variant

Dim rng As Range
Set rng = Range("A2:a7")

Range("g1").FormulaArray = "=MIN(DATEVALUE(rng))"
str =   "=MIN(DATEVALUE(rng))"

End Sub


thanks
mg
 
Upvote 0
What are your dates in Text?
As long as we are using VBA, can we change them to actual Dates so they are easier to work with?
 
Upvote 0
Hi Joe,

I have converted into numbers.

Now How to get max and min date from it via vba.

Book1
ABCDE
1DateIS Number
201/02/2018TRUE
302/05/2018TRUEmax09/04/2020
402/05/2018TRUEMin01/02/2018
508/04/2020TRUE
609/04/2020TRUE
708/04/2020TRUE
Sheet1
Cell Formulas
RangeFormula
C2:C7C2=ISNUMBER(A2)


Thanks
mg
 
Upvote 0

Forum statistics

Threads
1,215,020
Messages
6,122,712
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top