comparing excel dates in vb macro

  • Thread starter lataa3 via OfficeKB.com
  • Start date
L

lataa3 via OfficeKB.com

I am just into vb macro. so Could anybody please help me out! I want to
know comparison of two dates of excel in macro, since there is mismatch of
formats (EXCEL :DD-MM-YY & VB:mm/dd/yy)

Could you help me coding - how to compare two dates in Macro.
Suppose A1 contains 28-11-00. I want to check whether the value in A1 is
LESS THAN 02-3-01 and greater than or equal to 16-12-98 .

Thanking you in anticipation

With regards
 
S

Stefi

Try this:
Print Range("A1") < DateSerial(2001, 3, 2) And Range("A1") >=
DateSerial(1998, 12, 16)

Regards,
Stefi

„lataa3 via OfficeKB.com†ezt írta:
 
M

Mishell

To compare apples with apples, You may want to try something like this:

result = CDate(Range("A1")) > CDate("28-11-00")

With regards

Mishell
 
F

filip

I am just into  vb macro. so Could anybody please help me out!   I want to
know comparison of two dates of excel in macro,  since there is mismatch of
formats (EXCEL :DD-MM-YY & VB:mm/dd/yy)

Could you help me coding  - how to compare two dates in Macro.
Suppose A1  contains  28-11-00.   I want to check  whether the value in A1 is
LESS THAN   02-3-01 and greater than or equal to 16-12-98  .

Thanking you in anticipation

With regards

You can use GemBox.Spreadsheet: http://www.gemboxsoftware.com/GBSpreadsheet..htm
It can read different date formats, convert it to one and then easily
compare
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top