ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   simplify date input (https://www.excelbanter.com/excel-programming/409311-simplify-date-input.html)

Helmut

simplify date input
 
I have the following macro -- it works, but could somone simplify it for me
please?

' Format Column Q for date
Range("Q1").Select
Selection.NumberFormat = "dd/mm/yyyy"

' input payroll month

Range("S1").Select

' Dim Message, Title, Default, Myvalue

Message = "Enter Payroll Month date i.e. 05/01/2008 for May 2008" '
Set prompt.
Title = "Input Box"
' Set title.
Default = "05/01/2008"
' Set default.

' Display message, title, and default value.
Myvalue = InputBox(Message, Title, Default)

ActiveCell.FormulaR1C1 = Myvalue


' Enter EndOfMonth formular and copy down
Range("Q1").Select
ActiveCell.FormulaR1C1 = "=EOMONTH(R1C19,0)"
Selection.Copy
ActiveCell.Offset(0, -2).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 2).Range("A1").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

' Column Autofit and delete not-needed Cell
Columns("Q:Q").EntireColumn.AutoFit
Range("S1").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp


All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com