Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Devuelve fecha errónea en Combobox

publicado

Buenas, tengo el siguiente problema, una vez genero la fecha d, los valores que extraigo son erróneos y me sale por defecto en año = 1905, mes = 01(enero) y día = 29, cuando obviamente no estamos a esa fecha. No he encontrado la solución por ningún sitio, y estoy un poco verde en esto, si alguien me puede echar una mano lo agradecería! Saludos :)

 

 

 

Private Sub ComboBox4_Change()
'Se utiliza para poder generar un numero de oferta
 Range("B3").Select
   Selection.End(xlDown).Select
   seleccion = ActiveCell.Row


        d = Date
        
        y = Format(Year(d), "yyyy")

        m = Format(Month(d), "mm")
        
        dia = Format(Day(d), "dd")

                    
                    
                    Select Case ComboBox4
                                                                
                            Case "Material"
                            'Generar # oferta de material
                            Dim mat As String
                            mat = "C16/" & dia & m
                            Cells(seleccion, 3) = mat


                            Case "Proyecto"
                            'Generar # oferta de proyecto
                            Dim proy As String
                            proy = "16/" & dia & m
                            Cells(seleccion, 3) = proy                                                           
                                
                    End Select

End Sub

Featured Replies

publicado

Hola

 

Quita el Format cuando lo aplicas a d y aplícaselo a  y, m y dia

        d = Date
        y = Year(d)
        m = Month(d)
        dia = Day(d)
        y = Format(d, "yyyy")
        m = Format(y, "mm")
        dia = Format(dia, "dd")

 

Un saludo desde Vitoria

publicado
  • Autor

Muchas gracias

Hace 2 horas, ioyama dijo:

Hola

 

Quita el Format cuando lo aplicas a d y aplícaselo a  y, m y dia

        d = Date
        y = Year(d)
        m = Month(d)
        dia = Day(d)
        y = Format(d, "yyyy")
        m = Format(y, "mm")
        dia = Format(dia, "dd")

 

Un saludo desde Vitoria

Muchas gracias, me has dado el kit de la respuesta, tuve que cambiar al final a lo que se ve abajo, el resto era redundante. Lo dejo por si a alguien le pudiera ser de ayuda, y gracias de nuevo ioyama!!

        f = Date
        y = Format(f, "yyyy")
        m = Format(f, "mm")
        dia = Format(f, "dd")

Pasa buen dia!

  • Silvia bloqueó este tema

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.