T
TroyB
Hi,
I have the following extract of code requiring the user to input the date
into a prompt and then inserted into the spreadsheet.
Sub DateTest()
dateformat = Format(Now(), "dd mmm yyyy")
PayDate = Application.InputBox("Input Pay Date to appear on Payslips", "DATE
REQUIRED", dateformat)
Range("A1").Value = PayDate
End Sub
I have recently been educated that using the "Option Explicit Statement" is
a good way to ensure declaration of all variables and i tend to agree with
this philosophy as the code is becoming larger (and complex!). But when i
use the following code (including the declaration of variables), i can't get
it to provide the date format i require, ie "dd mmm yyyy".
Option Explicit
Sub DateTest()
Dim PayDate As Date, DateFormat As Date
DateFormat = Format(Now(), "dd mmm yyyy")
PayDate = Application.InputBox("Input Pay Date to appear on Payslips",
"DATE REQUIRED", DateFormat)
Range("A1").Value = PayDate
End Sub
Using Option Explicit, how can i provide a default input of todays date in
"dd mmm yyyy" format and, following the user input insert the date into the
spreadsheet in the format "dd mmm yyyy"?
Thanks in advance
Boeky
I have the following extract of code requiring the user to input the date
into a prompt and then inserted into the spreadsheet.
Sub DateTest()
dateformat = Format(Now(), "dd mmm yyyy")
PayDate = Application.InputBox("Input Pay Date to appear on Payslips", "DATE
REQUIRED", dateformat)
Range("A1").Value = PayDate
End Sub
I have recently been educated that using the "Option Explicit Statement" is
a good way to ensure declaration of all variables and i tend to agree with
this philosophy as the code is becoming larger (and complex!). But when i
use the following code (including the declaration of variables), i can't get
it to provide the date format i require, ie "dd mmm yyyy".
Option Explicit
Sub DateTest()
Dim PayDate As Date, DateFormat As Date
DateFormat = Format(Now(), "dd mmm yyyy")
PayDate = Application.InputBox("Input Pay Date to appear on Payslips",
"DATE REQUIRED", DateFormat)
Range("A1").Value = PayDate
End Sub
Using Option Explicit, how can i provide a default input of todays date in
"dd mmm yyyy" format and, following the user input insert the date into the
spreadsheet in the format "dd mmm yyyy"?
Thanks in advance
Boeky