Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
A better way to browse. Learn more.
A full-screen app on your home screen with push notifications, badges and more.
Este tema está ahora archivado y está cerrado a más respuestas.
Hola a toda la gente del foro, hoy les traigo un código que fui recopilando y en el cual personas de este foro me han ido ayudando en armar. Lo que no puedo lograr es introducirla en un módulo y poder llamarla siempre que yo lo requiera.
Call CARGAR_COMBOBOX("BASE", "N_SE")
Function CARGAR_COMBOBOX(HOJA As String, POSBUS As String) As String
Dim Dir As String
'ACTIVA LA HOJA: "BASE"
Worksheets(HOJA).Activate
'ACTIVA LA CELDA A1
ActiveSheet.Range("A1").Activate
'BUSCA LA COLUMNA SEGÚN LA ETIQUETA INDICADA
Do While ActiveCell.Value <> POSBUS
'REALIZA UN DESPLAZAMIENTO (FILA,COLUMNA) Y ACTIVA LA CELDA
ActiveCell.Offset(0, 1).Activate
Loop
'GUARDA EL ADDRESS DE LA COLUMNA ACTIVA
COLUMNA = ActiveCell.Column
Dir = Columns(COLUMNA).Address(0, 0)
Dir = Left(Dir, InStr(Dir, ":") - 1)
LETRA_COLUMNA = Dir
'DEFINE EL RANGO DONDE VA A IR A BUSCAR LOS DATOS DEL COMBOBOX (CELDA INICIAL,CELDA FINAL)
Set rango = Range(LETRA_COLUMNA & 1, Range(LETRA_COLUMNA & 1).End(xlDown))
rango.AdvancedFilter 2, , Range("IV1"), Unique:=True
Range("IV:IV").Sort Range("IV1"), xlAscending, Header:=xlYes
'LIMPIA LA VARIABLE
N_SE.Clear
For Each vp In Range("IV:IV").SpecialCells(xlCellTypeConstants)
N_SE.AddItem vp.Value
Next
N_SE.RemoveItem (0)
Range("IV:IV").EntireColumn.SpecialCells(xlCellTypeConstants).ClearContents
Set rango = Nothing
End Function[/CODE]
Cuando lo quiero ejecutar me tira el error 424 - Se requiere un objeto
Desde ya muchas gracias todos. Saludos!