Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

210
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda