View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default vba code needed for date

VBA is a derivative of VB which has no relation to office at all. VB is a
derivative of basic which has been around a lot longer than office. VBA was
later chosen to be a common scripting capability in Office and other apps -
such as Autocad (which all have a legacy macro language (autocad uses a
form of lisp)). Any consistency is probably more of a coincidence.

--
Regards,
Tom Ogilvy


"GB" wrote in message
...

"David Turner" wrote in message
...
GB wrote

Range("A3").Value = DateAdd("m", 1, Range("A3").Value)


Excellent!!

Much more compact (I like compact) than what I finally stumbled onto:

dte = DateValue(Range("A3").Value)
Range("A3") = DateSerial(Year(dte), Month(dte) + 1, 1)

Thanks.

--
David


Thanks David.

I take it that you can also find it difficult to track down the function
that you want to use in VBA. I think that that is because VBA is rather
inconsistent with the underlying apps.

For example, the Date function in Excel worksheets does the same as
DateSerial in VBA, whereas the Date function in VBA returns the current
system date. The reason is that other Office applications like word use

the
Date 'field' to mean current system date, whilst Excel uses Today or Now

for
that.

Hardly surprising that VBA is so inconsistent and arcane in places when

the
underlying applications were clearly written by different teams who did

not
speak to each other. In fact, I seem to recall that the applications were
originally bought in by Microsoft from different companies and merely
branded together as Office. VBA is where the different apps meet up, and
that's where the inconsistencies stand out.

Geoff