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.

Ayuda macro

publicado

Buenas a todos,

Necesito ayuda para una macro que no tengo forma de hacerla.

Tengo una tabla con 5 columnas, sus encabezados se llaman “A”, “B”, “C”, “D” y “E”.

Busco datos en las columnas A B C y D, y cuando coincidan me den el dato que hay en la celda correspondiente de la columna E.

Muchas gracias de antemano.

Featured Replies

publicado

He añadido un columna nueva a tu base de datos y he cambiado el código para ver si comprendes mejor su funcionamiento.image.thumb.gif.a7dc8fcde1abc7d7a01e4ee22cf3e53d.gif

Los datos te los muestra tanto en el formulario como puedes ver  así como en la hoja valores

publicado
Private Sub ACEPTAR_Click()
    Dim ws As Worksheet
    Dim rng As Range
    Dim cell As Range
    Dim vmodelo As String
    Dim vpresostato As String
    Dim vvelocidad As String
    Dim vrecorrido As Double
    Label97.Visible = False
    ' Aquí habilitamos el botón de "Ir a Excel".
    Me.SALIR.Enabled = True
    ' Establecer la hoja de trabajo
    Set ws = ThisWorkbook.Sheets("Datos hidráulicos")
    ' Definir las variables según tus controles en el formulario
    vmodelo = MODELO
    vrecorrido = RECORRIDO
    If Me.CheckBox_PRESOSTATO = True Then vpresostato = "SI"
    If Me.CheckBox_PRESOSTATO = False Then vpresostato = "NO"
    If Me.OptionButton_010MS = True Then vvelocidad = "0,10 m/s."
    If Me.OptionButton_015MS = True Then vvelocidad = "0,15 m/s."
    If Me.OptionButton_020MS = True Then vvelocidad = "0,20 m/s."
    ' Aplicar el filtro
    With ws.Range("A1").CurrentRegion
        .AutoFilter 1, vmodelo
        .AutoFilter 3, vpresostato
        .AutoFilter 4, vvelocidad
        
        ' Manejar el error en caso de que no haya celdas visibles
        On Error Resume Next
        Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).SpecialCells(xlCellTypeVisible)
        On Error GoTo 0 ' Restaurar el manejo normal de errores
        
        If rng Is Nothing Then
            MsgBox "No hay datos con las características solicitadas.", vbInformation
        Else
            ' Recorrer las filas visibles después de aplicar el filtro
            For Each cell In rng
                ' Verificar si vrecorrido está en el rango E:F
                If CDbl(RECORRIDO) >= .Cells(cell.Row, 5) _
                    And CDbl(RECORRIDO) <= .Cells(cell.Row, 6) Then
                    Hoja21.Cells(6, 1) = vmodelo
                    Hoja21.Cells(1, 4) = vmodelo
                    Hoja21.Cells(2, 4) = .Cells(cell.Row, 7)
                    Hoja21.Cells(3, 4) = .Cells(cell.Row, 8)
                    Hoja21.Cells(5, 4) = vvelocidad
                    Label97.Visible = True
                    Label97 = .Cells(cell.Row, 8) & vbCrLf & .Cells(cell.Row, 7)
                    If Len(.Cells(cell.Row, 8)) > 8 Then
                        Label97.Font.Size = 40
                    Else
                        Label97.Font.Size = 55
                    End If
                    Exit For
                End If
            Next cell
        End If
        .AutoFilter
    End With
End Sub

 

1(1) (1).xlsm

publicado
  • Autor

Muchas gracias Jesús!!

Estoy de viaje, mañana en cuanto llegue lo miro.

Gracias de nuevo!!!

Saludos.

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.