Colocar Comentarios en macro excel

Esta macro (código) me la entrego el amigo luismondelo pero ahora voy y no está disponible.

Quisiera que algún experto me comentase el código con lineas de comentario para mejor entenderlo yo. Las que contiene fui yo mismo que lo hice pero no se si estarán bien pero faltan las demás lineas

Private Sub UserForm_Initialize()
'Agregar datos al ComboBox
Sheets("hoja2").Select 'Hoja Donde se encuentran los datos
Range("g2").Select 'rango inicial
Range("g65000").End(xlUp).Offset(1, 0).Value = "final" 'rango final
Do While ActiveCell.Value <> "final"
If ActiveCell.Value <> "" Then
ComboBox1.AddItem ActiveCell
End If
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.ClearContents 'borra contenido de la celda activa
End Sub

Gracias

1 respuesta

Respuesta
1

Como yo la hice yo te contesto:

Private Sub UserForm_Initialize()
'Agregar datos al ComboBox
Sheets("hoja2").Select 'Hoja Donde se encuentran los datos
Range("g2").Select 'rango inicial
Range("g65000").End(xlUp).Offset(1, 0).Value = "final" 'ponemos la palabra final en la última celda
Do While ActiveCell.Value <> "final" 'ejecutamos el bucle hasta encontrar la palabra final
If ActiveCell.Value <> "" Then 'si la celda es distinta de nada....
ComboBox1.AddItem ActiveCell 'añadimos la celda al combo
End If 
ActiveCell.Offset(1, 0).Select 'bajamos una celda
Loop
ActiveCell.ClearContents 'borra contenido de la celda que contiene la palabra final
End Sub

recuerda finalizar

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas