Hey everyone,
New to this forum!
Trying to look for a way to use one userform to enter several values in the same row by changing values in a list box.
The userform asks for name, sex, a listbox with options for clothes (jacket, shirt, pants), a text box to specify how many items, a text box to specify the size (4,6,8..), and a text box for observations.
In the same row (for the same person) i need a button that allows the person to enter information for each choice of clothes (changing the values in the listbox), and another button that will look for the next free row.
I have the following but it only runs the first If condition until the end of the For Loop.
I apologize if some of the strings are in spanish but the people I work for are spanish speakers.
--------------------------------------------
New to this forum!
Trying to look for a way to use one userform to enter several values in the same row by changing values in a list box.
The userform asks for name, sex, a listbox with options for clothes (jacket, shirt, pants), a text box to specify how many items, a text box to specify the size (4,6,8..), and a text box for observations.
In the same row (for the same person) i need a button that allows the person to enter information for each choice of clothes (changing the values in the listbox), and another button that will look for the next free row.
I have the following but it only runs the first If condition until the end of the For Loop.
I apologize if some of the strings are in spanish but the people I work for are spanish speakers.
--------------------------------------------
Code:
Private Sub CmdTransfer_Click()
Sheets("DatosTotal").Select
'ActiveSheet.Unprotect
Dim i As Integer
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("DatosTotal")
Sheets("DatosTotal").Range("B7").Select
'find first empty row in database
For iRow = 8 To 20
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
ws.Cells(iRow, 2).Value = Me.txtNombres.Value
ws.Cells(iRow, 3).Value = Me.LBgenero.Value
If (Me.LBprenda.Value = "CHAQUETAS") Then
ws.Cells(iRow, 6).Value = Me.CBunid1.Value
ws.Cells(iRow, 7).Value = Me.CBtalla.Value
ws.Cells(iRow, 8).Value = Me.txtObs.Value
Me.LBprenda.SetFocus
If (Me.LBprenda.Value = "CHALECO") Then
ws.Cells(iRow, 9).Value = Me.CBunid1.Value
ws.Cells(iRow, 10).Value = Me.CBtalla.Value
ws.Cells(iRow, 11).Value = Me.txtObs.Value
If (Me.LBprenda.Value = "PANTALON") Then
ws.Cells(iRow, 12).Value = Me.CBunid1.Value
ws.Cells(iRow, 13).Value = Me.CBtalla.Value
ws.Cells(iRow, 14).Value = Me.txtObs.Value
If (Me.LBprenda.Value = "FALDA") Then
ws.Cells(iRow, 15).Value = Me.CBunid1.Value
ws.Cells(iRow, 16).Value = Me.CBtalla.Value
ws.Cells(iRow, 17).Value = Me.txtObs.Value
If (Me.LBprenda.Value = "BLUSA") Then
ws.Cells(iRow, 18).Value = Me.CBunid1.Value
ws.Cells(iRow, 19).Value = Me.CBtalla.Value
ws.Cells(iRow, 20).Value = Me.txtObs.Value
End If
End If
End If
End If
End If
Next
MsgBox "Datos han sido ingresados", vbOKOnly + vbInformation
'clear the data
Me.txtNombres.Value = ""
Me.LBgenero.Value = ""
Me.CBunid1.Value = ""
Me.CBtalla.Value = ""
Me.txtObs.Value = ""
Me.txtNombres.SetFocus
Sheets("DatosTotal").Select
End Sub
Last edited by a moderator: