Cargar datos en formulario

ANtrax

New Member
Joined
Nov 9, 2009
Messages
1
estimados amigos del foro recurro a ustedes para que me puedan dar una manito sobre una aplicacion que estoy desarrollando

el libro consta de 3 hojas y trata de una aplicacion que me ayude a organizar las compras

la primera hoja contiene 2 botones el primero llama un formulario crear proveedor, en este el usuario ingresa los datos del proveedor a crear y al guardar con un boton el el formulario los datos se guardan en una tabla en la hoja 2 ( eso ya lo tengo controlado)

Ahora en boton 2 carga un formulario donde se ingresan los datos de la compra.

existe un combobox que recoge el nombre de los proveedores de la tabla en la hoja 2 eso tambien ya lo tengo lo organiza alfabeticamente y obvia los vacios, cuando seleccione un nombre de este combobox me deberia cargar los textboxt 1 al 6 con datos del proveedor seleccionado de la tabla en la hoja 2, y lo hace pero no me carga los datos que corresponden a el nombre pues al parecer se debe a que el combobox ordena y ese orden no corresponde a los valores.

Private Sub UserForm_Initialize()
Dim Fila As Long, i As Long
ComboBox1.Clear
uf = Sheets("Proveedores").Range("A" & Cells.Rows.Count).End(xlUp).Row
Fila = 1
Do While Sheets("Proveedores").Cells(Fila, 1).Row <= uf
CargarList ComboBox1, Sheets("Proveedores").Cells(Fila, 1).Value, True
Fila = Fila + 1
Loop
End Sub

Private Function CargarList(ByVal List As Variant, ByVal Dato As String, ByVal EvitarRepetidos As Boolean)
'EvitarRepetidos = True
For i = 0 To List.ListCount - 1
If Dato = "" Then Exit Function
If List.List(i) = Dato Then Exit Function
If List.List(i) > Dato Then Exit For
Next
List.AddItem Dato, i
End Function


Private Sub aUserForm_Initialize()
n = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To n
If Cells(i, 1) <> "" Then
ComboBox1.AddItem Cells(i, 1).Value
End If
Next i
End Sub

Private Sub CommandButton1_Click()

End Sub
Application.ScreenUpdating = False

Dim iFila As Long
Dim ws As Worksheet
Set ws = Worksheets(2)



'Comprueba que ningún dato quede vacio
If TextBox1.Value = "" Or TextBox2.Value = "" Or ComboBox1.Value = "" Or TextBox3.Value = "" Or TextBox4.Value = "" Or _
TextBox5.Value = "" Or TextBox6.Value = "" Or TextBox7.Value = "" Or TextBox8.Value = "" Or TextBox9.Value = "" Or TextBox10.Value = "" Or _
TextBox11.Value = "" Or TextBox12.Value = "" Or TextBox13.Value = "" Or TextBox14.Value = "" Or TextBox15.Value = "" Then
MsgBox "Diligencie todos los Campos Vacios"
Exit Sub
End If

Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub ComboBox1_Change()
Fila = ComboBox1.ListIndex + 2
'TextBox1.Value = Worksheets("Hoja2").Cells(Fila, 2)
Worksheets("Proveedores").Select
TextBox2.Value = Worksheets("Proveedores").Cells(Fila, 2)


End Sub

gracias por favor una manito
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,215,217
Messages
6,123,670
Members
449,115
Latest member
punka6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top