Insert date in macro

G

George Gee

Happy new year to all!

I recorded this macro some time ago, the cell A5 is selected at the end of
the macro,
ready for the user to insert today's date.
How do I edit the macro to insert today's date into cell A5, when it is run.

I do not want to use =TODAY() as this would change the date, daily,
(does that make sense)?

Many thanks
 
A

Andy Brown

How do I edit the macro to insert today's date into cell A5, when it is
run.

Add at end:

Range("Sheet1!A5") = Date

Rgds,
Andy
 
H

Harald Staff

Hi George

Sure. It is very simple:

Range("A5").Value = Date

You can also use Now (for date and time) and Time (for time without date)

HTH. Best wishes Harald
 
G

George Gee

I suppose it would help if I included the macro!

Range("A5:G5").Select
Selection.Insert Shift:=xlDown
Range("B3:F3").Select
Selection.Copy
Range("B5:F5").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Range("B3:F3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("B5").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=IF(B5>B6,TRUE)"
Selection.FormatConditions(1).Font.ColorIndex = 5
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=IF(B5<B6,TRUE)"
Selection.FormatConditions(2).Font.ColorIndex = 3
Selection.Copy
Range("B5:F5").Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Application.CutCopyMode = False
Range("A5").Select
End Sub

*George Gee* has posted this message:
 
G

George Gee

Andy, Harald.

Thank you very much, just what I wanted!

George Gee



*Harald Staff* has posted this message:
 

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