VBA code_lisparc

1. Count the days between US format and UK format.
‘Run below code and get the green cells.
‘The idea is to set column E to be Date UK format first (or later), and then write formula ‘=Today()’ in cell E2. The date is displayed as UK format by force even it is US formate in system, then we can use ‘=F2-B2’ or ‘=Datedif()’ to get the different days.

‘KZ code
Sub today02()

‘ today02 Macro
‘ Count the days between US and UK format by Today()

Selection.NumberFormat = “dd/mm/yyyy;@”
ActiveCell.FormulaR1C1 = “=TODAY()”
Selection.AutoFill Destination:=Range(“E2:E4”), Type:=xlFillDefault
ActiveCell.FormulaR1C1 = “=RC[-1]-RC[-4]”
Selection.AutoFill Destination:=Range(“F2:F4”), Type:=xlFillDefault
End Sub

This entry was posted in Computer science. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s