English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do I put a date into a cell when you click a button and concatenate it with the current value
Dim NextID As Integer
Dim Today As Date
Today = Now
NextID = Range("a1") + 1
Range("a1") = NextID

so I want NextID + Todays date

so it enters in The NextID100107 for example
Range("b6") = NextID

2007-01-10 07:28:11 · 3 answers · asked by OAIS1 2 in Computers & Internet Programming & Design

3 answers

LOL yeah, the VB language does support concatenation with bouth & and +, but with + you have to implicitly convert a value that is not a string: Range("a1") = NextID + cstr(today)

note that Now() will output also time, not only date.

2007-01-10 07:47:25 · answer #1 · answered by Julio M 3 · 0 0

change the NextID variable-type to Long. the Integer type cannot cope with number greater than 32767.


Sub adate()
Dim NextID As Long
Dim Today As Date
Today = Format(Now, "dd/mm/yy")
Range("A1") = Range("A1") + 1
NextID = Range("A1") + Today
Range("B6") = NextID
End Sub

2007-01-10 17:00:59 · answer #2 · answered by Anonymous · 1 0

Range("b6") = NextID & Today

2007-01-10 15:39:23 · answer #3 · answered by rod 6 · 0 0

fedest.com, questions and answers