Formula for a date

  • Thread starter Thread starter ExcelConfussed
  • Start date Start date
E

ExcelConfussed

Can anyone advice me on how get the current date to display in a field
when I open a excel template I created.
 
Not sure what you mean by "Field".

Code :
Range("A1").Value = Format(Date, "dd/mm/yy")

or, a simple formula in a cell :-
=NOW() and format cell accordingly
 
Thanks for your help. I guess by field I meant cell! The formulas you
gave me worked thanks. Can you also set it that the date will only
appear when you select that specific cell with the formula in it?
 
Thanks for your help. I guess by field I meant cell! The formulas you
gave me worked thanks. Can you also set it that the date will only
appear when you select that specific cell with the formula in it?

You could try an event-triggered macro like:

======================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, [A5]) Is Nothing Then
Range("a5").Font.Color = Range("a5").Interior.Color
Else
Range("a5").Font.Color = vbBlack
End If
End Sub
======================

Assumes your formula is in A5.

To enter, right click on the worksheet tab and select View Code. Paste the
above code into the window that appears.


--ron
 

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

Back
Top