User Tools

Site Tools


microsoft_excel:macro_change_format_of_date

This is an old revision of the document!


Microsoft Excel - Macro Change format of date

Dim lastrow_sheet123 As Long
 
 
' Get how many rows of data have been loaded into the sheet.
lastrow_sheet123 = .Cells(Rows.Count, 4).End(xlUp).Row
' Prevent line 2 being deleted - as this contains the formulae which need coping down later.
If lastrow_sheet123 < 3 Then
  lastrow_sheet123 = 3
End If
 
 
' Convert the date using a formula.
' In order to convert the date it is necessary to use a formula that copies the data from the input file instead of copy/pasting it.
.Range("C2").Formula = "=if('DIVI - Auto'!J2>9999999,DATE(RIGHT('Sheet123'!J2,4),MID('Sheet123'!J2,3,2),LEFT('Sheet123'!J2,2)),DATE(RIGHT('Sheet123'!J2,4),MID('DIVI - Auto'!J2,2,2),LEFT('Sheet123'!J2,1)))"
 
 
 
' Change format of date.
 
.Range("C2:C" & lastrow_sheet123).NumberFormat = "yyyymmdd"
.Range("C2:C" & lastrow_sheet123).Calculate
microsoft_excel/macro_change_format_of_date.1594805433.txt.gz ยท Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki