
Registrar datos de un ListBox en un rango junto con datos de otros controles
Publicado por Willian Ernesto (3 intervenciones) el 15/11/2014 20:55:40
"GUARDAR LOS ITEMS DE UN LISTBOX Y A LA VEZ LOS DE OTROS CONTROLES"
Hola amigos,
Antes que todo el Lenguaje es VBA
Soy novato en esto y necesito de su conocimiento para aclarar mi duda:
Tengo el siguiente Form:

En el tengo un ListBox el cual ya logre que se copiara en el rango deseado, así como también que los otros datos de los demás controles lo que no logro aún es que la fila donde estan los datos de los demás controles se rellenen junto con los del ListBox, para mayor referencia echen un vistazo al código
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Private Sub CommandButton1_Click()
Sheets("GENERAL").Select
Range("A10000").Select
ActiveCell.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = Me.TextBox1.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox2.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox3.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.ComboBox1.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.ComboBox6.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox4.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.ComboBox2.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.ComboBox3.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox5.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox6.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox7.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox8.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox10.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox11.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox12.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox24.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox23.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Me.TextBox25.Value
ActiveCell.Offset(0, 1).Select
For J = 0 To ListBox1.ColumnCount
For X = 0 To ListBox1.ListCount - 1
ActiveCell.Offset(X, J).Value = ListBox1.List(X, J)
Next
Next
ActiveCell.Offset(0, -18).Select
Dim celda_inic As String
Dim celda_fin As String
celda_inic = LTrim("A" & Str(ActiveCell.Row))
celda_fin = LTrim("R" & Str((ActiveCell.Row + ListBox1.ListCount - 1)))
Dim rango_fill As Range
Set rango_fill = Range(celda_inic & ":" & celda_fin)
rango_fill.Select
Selection.FillDown
End Sub
Pero obtengo el siguiente resultado:
En la hoja:

y surge el siguiente Error:

yo deduzco que el problema es que no reconoce el rango que establezco luego del los For
Espero que me apoyen, creo que es una buena oportunidad para aprender... Espero sus mensajes
Valora esta pregunta


0