LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Convert Date

From the below code iam trying to compare my active cell with previous date
, if the active cell is less than previous month then the result need to be
Yes, else No.

The problem iam facing from the below code in variable mmyy, when i run
macro this variable is shown as Text inspite of Date because of which its not
able to compare with previous date.

Example: my date column is copied from MSAccess so the date is in exact this
formate SEP-08

sub test()
PrvMth = Format(DateSerial(Year(Date), Month(Date) - 1, 1), "mmyy")
ActiveCell.Offset(1, 0).Select
a = ActiveCell
m = DatePart("m", a)
If (m < 10) Then
m = 0 & m
End If
y = Right(a, 2)
mmyy = m & y
MsgBox mmyy & vbLf & PrvMth
If mmyy < PrvMth Then
ActiveCell.Offset(0, 1) = "Yes"
Else
ActiveCell.Offset(-1, 0).Select
End If
End If
End If
End sub
 
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 convert US date with 12hr format to European date 24hr Enda K Excel Discussion (Misc queries) 1 November 15th 09 09:59 AM
Is it possible to convert solar date to lunar date using excel? GOH Excel Discussion (Misc queries) 1 October 25th 09 09:21 AM
How to convert Gregorian date into Hijri Date in Excel 2007? Ahmed Excel Discussion (Misc queries) 2 February 6th 09 03:59 PM
How do you convert an uncoded date (e.g., 20080304) to a date form tenorofchange Excel Worksheet Functions 5 April 20th 08 02:56 PM
Convert a julian gregorian date code into a regular date Robert Excel Worksheet Functions 3 June 13th 06 07:03 PM


All times are GMT +1. The time now is 05:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"