Hello,
Probably this is a very silly question, but I need some help
I have a form which was working well, showing me this information
In my excel sheet, Id was column 1, Name colum 2 and Last Name was Column 3. This is the code that I had:
but I had to add a New column in my sheet "Registers", so now Id is colum 2, Name is column 3 and Last Name is column 4, the problem is that the information is not being displayed properly, just shows me the Id but not name and last name.
This is the code that I am using now
I don't know if is something related to the form initialize, where I have this piece of code
Thanks for the help in advance
Probably this is a very silly question, but I need some help
I have a form which was working well, showing me this information
In my excel sheet, Id was column 1, Name colum 2 and Last Name was Column 3. This is the code that I had:
VBA Code:
With Worksheets("Registers")
filas = .Range("A1").CurrentRegion.Rows.Count
For i = 2 To filas
If LCase(.Cells(i, 2).Value) Like "*" & LCase(Me.txtFiltro1.Value) & "*" Then
j = j + 1
Me.ListBox1.AddItem .Cells(i, 1)
Me.ListBox1.list(Me.ListBox1.ListCount - 1, 1) = .Cells(i, 1).Offset(0, 1)
Me.ListBox1.list(Me.ListBox1.ListCount - 1, 2) = .Cells(i, 1).Offset(0, 2)
End If
Next i
If j = 0 Then MsgBox "Nothing found"
End With
but I had to add a New column in my sheet "Registers", so now Id is colum 2, Name is column 3 and Last Name is column 4, the problem is that the information is not being displayed properly, just shows me the Id but not name and last name.
This is the code that I am using now
VBA Code:
Private Sub CommandButton5_Click()
With Worksheets("Registers")
filas = .Range("A1").CurrentRegion.Rows.Count
For i = 3 To filas
If LCase(.Cells(i, 3).Value) Like "*" & LCase(Me.txtFiltro1.Value) & "*" Then
j = j + 1
Me.ListBox1.AddItem .Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = .Cells(i, 1).Offset(0, 3)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = .Cells(i, 1).Offset(0, 4)
End If
Next i
If j = 0 Then MsgBox "Nothing found"
End With
End Sub
I don't know if is something related to the form initialize, where I have this piece of code
VBA Code:
Private Sub UserForm_Initialize()
frmName.Show
Worksheets("Registers").Select
For i = 2 To 4
Me.Controls("Label" & i) = Cells(3, i).Value
Next i
With ListBox1
.ColumnCount = 3
.ColumnWidths = "30 pt;50 pt;50 pt"
End With
End Sub
Thanks for the help in advance
Last edited by a moderator: