Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Data Validation - Combo box usando Named Ranges – INDIRECT

Estas en el tema de Data Validation - Combo box usando Named Ranges – INDIRECT en el foro de Visual Basic clásico en Foros del Web. Estoy adaptando la siguiente macro: ------------------------------------------------------------------ Private Sub TempCombo_KeyDown(ByVal _ KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) 'Hide combo box and move to next ...
  #1 (permalink)  
Antiguo 09/04/2007, 09:06
 
Fecha de Ingreso: abril-2007
Mensajes: 2
Antigüedad: 17 años
Puntos: 0
Data Validation - Combo box usando Named Ranges – INDIRECT

Estoy adaptando la siguiente macro:

------------------------------------------------------------------
Private Sub TempCombo_KeyDown(ByVal _
KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
'Hide combo box and move to next cell on Enter and Tab
Select Case KeyCode
Case 9
ActiveCell.Offset(0, 1).Activate
Case 13
ActiveCell.Offset(1, 0).Activate
Case Else
'do nothing
End Select

End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Cancel = True
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
On Error GoTo errHandler
If Target.Validation.Type = 3 Then
Application.EnableEvents = False
str = Target.Validation.Formula1
str = Right(str, Len(str) - 1)
With cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 15
.Height = Target.Height + 5
.ListFillRange = ws.Range(str).Address
.LinkedCell = Target.Address
End With
cboTemp.Activate
End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet

Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
If cboTemp.Visible = True Then
With cboTemp
.Top = 10
.Left = 10
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
.Value = ""
End With
End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub
----------------------------------------------------------
Mi objetivo es usar una Lista de Validación pero pudiendo modificar el tamaño de la fuente e incluyendo una funcionalidad de Autocompletar.

Esta macro funciona perfectamente bien cuando uso Rangos de Validación directamente, pero cuando tengo la función INDIRECTO o fórmulas como lista de Validación deja de funcionar.

¿ Puede alguien ayudarme a modificar el código para poder usar la función INDIRECTO u otras funciones en la lista de validación ?

Gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:15.