Jump to content
News Ticker
  • Welcome to the Community
  • Use the forum to troubleshoot your Excel & VBA Problems
  • We will be launching a new website soon! www.ExcelWTF.com/Learn ! Join us to learn VBA from the ground up!

[VBA Snippet] Add Today's Date to Active Cell

Recommended Posts


To add the current date to the Active Cell, Contrained to a particular sheet and 2 columns.



Sub AddTodaysDate()
'=========== Purpose ===========
'The Purpose of the subroutine is to add the current date as a text value
Dim TodaysDate As String
Dim shName As String

'Checks if the macro is being used on the correct Sheet
If ActiveSheet.Name  "YourSheetName" Then
   Exit Sub
End If

If Not Intersect(ActiveCell, Range("D3:E1000")) Is Nothing Then
   TodaysDate = Format(Date, "mm/dd/yyyy") 'Assign todays date to variable as Text entry
   ActiveCell.Value = TodaysDate 'Insert todays date into cell C3
   ActiveCell.Font.Size = 8
   ActiveCell.Font.Name = "arial"
   MsgBox "You can only add todays date to Columns D & E of this sheet.", vbOKOnly, "Warning"
End If

End Sub

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...