Mega Code Archive

 
Categories / VisualBasic Script / Data Type
 

Displaying the current date and time in a cell

Sub DateAndTime()     TheDate = Format(Date, "Long Date")     TheTime = Format(time, "Medium Time")     Select Case time         Case Is < 0.5:     Greeting = "Good Morning, "         Case Is >= 0.7083: Greeting = "Good Evening, "         Case Else:         Greeting = "Good Afternoon, "     End Select     MsgBox TheDate & vbCrLf & TheTime, vbOKOnly, Greeting End Sub