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.

ComboBox en celdas varias.

publicado

¡Hola! 

Para cargar un ComboBox en un celda (con valores predeterminados de una lista) estoy utilizando el siguiente código:

 


Private Sub mycombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 13 Or KeyCode = 9 Then
        Range(mycombo.LinkedCell).Offset(1).Select
        If KeyCode = 13 Then ActiveCell.Offset(-1).Select
    End If
End Sub


Private Sub mycombo2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
   If KeyCode = 13 Or KeyCode = 9 Then
        Range(mycombo.LinkedCell).Offset(1).Select
        If KeyCode = 13 Then ActiveCell.Offset(-1).Select
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim Rng As Range, cmb As Object

    On Error Resume Next
    ActiveSheet.Shapes("mycombo").Delete
     ActiveSheet.Shapes("mycombo2").Delete
    On Error GoTo 0
    
    With Target
        If .Column <> 2 Or .Count > 1 Then Exit Sub
        .RowHeight = 30
        Set cmb = ActiveSheet.OLEObjects.Add(classtype:="Forms.ComboBox.1", Link:=False, _
        Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height)
        cmb.ListFillRange = "N1:N20"
        cmb.LinkedCell = .Address
        cmb.Name = "mycombo"
        cmb.Activate

  
  ¿Cómo separo estos dos código pero que funciones ambos? 
  
   If .Column <> 3 Or .Count > 1 Then Exit Sub
        .RowHeight = 30
        Set cmb = ActiveSheet.OLEObjects.Add(classtype:="Forms.ComboBox.1", Link:=False, _
        Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height)
        cmb.ListFillRange = "O1: O4"
        cmb.LinkedCell = .Address
        cmb.Name = "mycombo2"
        cmb.Activate
    End With
 
End Sub

El primer ComboBox funciona pero el segundo ya no aparece, no se como separar el código entre sí para que funcionens los dos (use un Elfe If pero me marca error).

Gracias. 

 

Editado el por OTOMEVIANEY2

Featured Replies

publicado

Revisa las normas del foro. Es obligatorio adjuntar un archivo Excel y describir con claridad lo que quieres.

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.