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()

Columns(“E:E”).Select
Selection.NumberFormat = “dd/mm/yyyy;@”
Range(“E2”).Select
ActiveCell.FormulaR1C1 = “=TODAY()”
Range(“E2”).Select
Selection.AutoFill Destination:=Range(“E2:E4”), Type:=xlFillDefault
Range(“E2:E4”).Select
Range(“F2”).Select
ActiveCell.FormulaR1C1 = “=RC[-1]-RC[-4]”
Range(“F2”).Select
Selection.AutoFill Destination:=Range(“F2:F4”), Type:=xlFillDefault
Range(“F2:F4”).Select
Range(“G2”).Select
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