Thread: VBA Date Format
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kieranz Kieranz is offline
external usenet poster
 
Posts: 12
Default VBA Date Format

Hi MVPs
I have 2 date cells formatted as dd mmm yyyy hh:mm:ss in Excel 2003
one is budget date in D3 and the other revise budget date in D4.

I have a macro that reads:
Option Explicit
Sub Chkdate()
Dim dBD as date
Dim dRBD as date

dBD = range("D3").value
dRBD = range("D4").value

If dBD < dRBD then ' problem comparison by vba includes the time as
well instead of
do xyz ' dd mmm yyyy only.
endif

What i would like to do is
IF format(dBD,dd/mmm/yyyy) < format(dRBD,dd/mmm/yyyy) then
do xyz
I am not a fundi (expert) in vba
Thks and Rgds
KZ