Hello... I'm a novice VB coder, so please bear with me if I'm doing something incorrectly that's totally simple. I've searched the forums, but haven't found anything that works for me.
I'm using a web query to download financial data into my spreadsheet. MSN's date column is only mon/yr in this format: mm/yy.
At first, since I had the sheet's column formatted as a date, what appeared was a bunch of numbers. In the forum, I saw the suggestion to format the column as TEXT first. OK, so I did that and dates now display like this:
6-Jun
5-Jun
4-Jun
3-Jun
2-Jun
1-Jun
Jun-00
Jun-01
Jun-02
Jun-03
Jun-04
OK, so I read on the web that Excel still has Y2K issues, so my next step was to try and convert the first group back into mm-yy.
I defined
tempdate as string
tempmonth as integer
tempyear as integer
realdate as date
and then performed a loop that includes
tempdate = ActiveCell.Value
If IsNumeric(Right(tempdate, 2)) = False Then Call convert_to_date
Then convert_to_date included:
tempmonth = Right(tempdate, 3)
If IsError(tempyear = Left(tempdate, 2)) = True Then
tempyear = "200" & Left(tempdate, 1)
Else
tempyear = "20" & (Left(tempdate, 2))
End If
realdate = tempmonth & tempyear
ActiveCell.Select
Selection.NumberFormat = "[$-409]mmm-yy;@"
ActiveCell.Value = realdate
I wasn't sure if testing a string's right 2 values for numbers would work, but I didn't even get that far because when I checked tempdate, the value shows up as 6/6/2006, 6/5/2006, etc. So the string is being converted back into a date. (Also, I have no idea if my code for conversion was anywhere near right. I coulnd't find anything in Excel Help on concatenation and took a wild guess on how to do it.)
So my questions are:
1) Is there a way to define tempdate that wouldn't let excel convert?
2) If not, how do I split that date to get month and year?
I worked on this for about 6 hours yesterday and I'm just tired of searching for things and wasting time. If anybody can help, I'd appreciate it greatly.
Thanks,
Kathy
Bookmarks