PC Review


Reply
Thread Tools Rate Thread

Can a vlookup be done on a 2 dimensional array?

 
 
davegb
Guest
Posts: n/a
 
      11th Nov 2008
I've never worked with VBA arrays before, and it's been many years since I
used them in a spreadsheet. Now I think they might help.

I have a spreadsheet with unusual dates. They're in MMM-YY format (no
days). I need to somehow convert them to month and year to compare with
some "normal" dates which are in mm/dd/yy format. Is it possible to create
a 2 dimensional array using Jan to Dec and 1 to 12 and then do a lookup to
get from the "mmm" in the spreadsheet to the month number to compare to
the "mm" in the date in the other column? Or do I have to put the months
and numbers into the spreadsheet and do a regular vlookup to convert from
text month to numeric month?

Thanks for your help.
 
Reply With Quote
 
 
 
 
Niek Otten
Guest
Posts: n/a
 
      11th Nov 2008
<They're in MMM-YY format>

Are they "real" Excel dates formatted asMMM-YY, or are they text strings?
If they are real Excel dates, just use Format>Cells>Number tab>Date and
choose an appropriate format.
If they are text strings, it depends on your date settings in Windows
Control Panel. Anyway, do try the DATEVALUE() function.
You can test whether it is a text string with the ISTEXT() function or the
other way around with the ISNUMBER() function (dates are numbers in Excel).
Last try indeed, use VLOOKUP tables. IŽd be surprised if that proved to be
necessary, but who knows.........


--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"davegb" <(E-Mail Removed)> wrote in message
news:1omtmidq7woib$.(E-Mail Removed)...
> I've never worked with VBA arrays before, and it's been many years since I
> used them in a spreadsheet. Now I think they might help.
>
> I have a spreadsheet with unusual dates. They're in MMM-YY format (no
> days). I need to somehow convert them to month and year to compare with
> some "normal" dates which are in mm/dd/yy format. Is it possible to create
> a 2 dimensional array using Jan to Dec and 1 to 12 and then do a lookup to
> get from the "mmm" in the spreadsheet to the month number to compare to
> the "mm" in the date in the other column? Or do I have to put the months
> and numbers into the spreadsheet and do a regular vlookup to convert from
> text month to numeric month?
>
> Thanks for your help.


 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      11th Nov 2008
On Wed, 12 Nov 2008 00:07:49 +0100, Niek Otten wrote:

> <They're in MMM-YY format>
>
> Are they "real" Excel dates formatted asMMM-YY, or are they text strings?
> If they are real Excel dates, just use Format>Cells>Number tab>Date and
> choose an appropriate format.
> If they are text strings, it depends on your date settings in Windows
> Control Panel. Anyway, do try the DATEVALUE() function.
> You can test whether it is a text string with the ISTEXT() function or the
> other way around with the ISNUMBER() function (dates are numbers in Excel).
> Last try indeed, use VLOOKUP tables. IŽd be surprised if that proved to be
> necessary, but who knows.........


Thanks for your reply. I should have mentioned that the "MMM-YY" dates are
actually text, not XL dates. I tried the DATEVALUE function, but for some
reason, the cell showed =DATEVALUE(F3) instead of the XL datevalue. It does
show the numerical datevalue in the DATEVALUE function dialog box! Never
saw that before. I guess DATEVALUE won't work here.

You didn't reply to my question about using an array to do a lookup. Is
this a possible way to go?
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      11th Nov 2008
You don't need a look up function... you can get the month number using a
formula like this...

=TEXT(--("1-"&A1),"m")

where I have assumed the MMM-YY "date" is in A1.

--
Rick (MVP - Excel)


"davegb" <(E-Mail Removed)> wrote in message
news:1omtmidq7woib$.(E-Mail Removed)...
> I've never worked with VBA arrays before, and it's been many years since I
> used them in a spreadsheet. Now I think they might help.
>
> I have a spreadsheet with unusual dates. They're in MMM-YY format (no
> days). I need to somehow convert them to month and year to compare with
> some "normal" dates which are in mm/dd/yy format. Is it possible to create
> a 2 dimensional array using Jan to Dec and 1 to 12 and then do a lookup to
> get from the "mmm" in the spreadsheet to the month number to compare to
> the "mm" in the date in the other column? Or do I have to put the months
> and numbers into the spreadsheet and do a regular vlookup to convert from
> text month to numeric month?
>
> Thanks for your help.


 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      12th Nov 2008
On Tue, 11 Nov 2008 18:42:03 -0500, Rick Rothstein wrote:

> =TEXT(--("1-"&A1),"m")


Thanks, Rick!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export 1-dimensional array values to a two-dimensional table? =?Utf-8?B?TGF1cmll?= Microsoft Excel Programming 2 8th Nov 2007 03:51 PM
Extracting single dimensional array out of two dimensional array Mukesh Microsoft C# .NET 5 24th Oct 2007 11:22 PM
flatten multi-dimensional array to on-dimensional array per9000 Microsoft C# .NET 8 4th Dec 2006 09:46 AM
copy 1 dimensional to 2 dimensional array with actual int values j-in-uk Microsoft C# .NET 3 12th May 2006 09:23 AM
RE: array copy from single-dimensional to multi-dimensional =?Utf-8?B?bWFyaw==?= Microsoft VB .NET 0 30th Jul 2004 11:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:34 PM.