Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
Flip dd/mm/yyyy format then cut it to another sheet

have a few subs running that aim to take the date of 2004/11/22 and change it to 04/11/2022. This updated date format will be pasted into a new sheet until the end row is hit based on Column A. Currently there is a debugging error and not the most familiar with VBA or debugging in general so any help would be appreciated thanks!

Sub TakeDate()
Sheets("Data Dump").Activate

Dim TakeDate As Date
' Two different versions from LM
' First is 2006-14-21 for June 14 2021
' Second is 6/14/21 for June 14 2021

If VarType(Range("G4").Value) = 7 Then
    TakeDate = Format(Range("G4").Value, "yyyy/mm/dd")
    
ElseIf InStr(Range("G4").Value, "-") <> 0 Then

    Dim strFull As String
    
    strFull = Range("G4").Value
    
    
    Dim month As String
    Dim dd As String
    Dim yy As String
    Dim dateFull As String
    
    
    month = Split(strFull, "-")(0)
    month = Right(month, 2)
    
    
    Select Case month
    Case Is = "01"
        month = "January"
    Case Is = "02"
        month = "February"
    Case Is = "03"
        month = "March"
    Case Is = "04"
        month = "April"
    Case Is = "05"
        month = "May"
    Case Is = "06"
        month = "June"
    Case Is = "07"
        month = "July"
    Case Is = "08"
        month = "August"
    Case Is = "09"
        month = "September"
    Case Is = "10"
        month = "October"
    Case Is = "11"
        month = "November"
    Case Is = "12"
        month = "December"
    End Select
    
    
    dd = Split(strFull, "-")(1)
    yy = Split(strFull, "-")(2)
    
    TakeDate = month + " " + yy + " " + dd
    MsgBox TakeDate
Else
    TakeDate = Format(Range("G4").Value, "yyyy/mm/dd")

End If

End Sub

Sub FindLastCell()
' Returns the last row # of an inputted column
' Used to reference where it will auto-fill to

Dim cell As Long
Dim FindLastCell As Long
Dim lastCell As Long
With Application.Worksheets("Daily Cumulations")
    lastCell = .Cells(.Rows.Count, cell).End(xlUp).row
End With

FindLastCell = lastCell


' Just learned you can use these below but the above works
' Columns("A").End(xlDown).Select
' Columns("A").End(xlDown).Offset(1,0).Select

End Sub

Sub FillDate()
' Input date
' Will auto-fill up to the last value of A col

Dim repDate As Date
Dim lastCell As String
Dim userIn As Date

lastCell = FindLastCell("A")
Columns("G").End(xlDown).Offset(1, 0).Select


'userIn = InputBox("Enter Date MMMM DD YYYY")
Range(Selection, "G" & FindLastCell("I")).Value = repDate

End Sub
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You could use a formula: =DATE(2000+DAY(A1),MONTH(A1),MOD(YEAR(A1),100))

Or as a public function, the following should work

Public Function ReverseDate(Src As Range) As String
    If Src.Cells.Count <> 1 Then Exit Function
    
    Dim dDate As Long: dDate = CDate(Src.Value)
    ReverseDate = DateSerial(2000 + Day(dDate), Month(dDate), Year(dDate) Mod 100)
End Function
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!