sharky12345
02-13-2017, 12:35 AM
I have a Listbox on a Userform which gets it's values from this;
Dim lastrow As Long
With Sheet1
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With Me.ListBox1
.ColumnCount = 15
.ColumnHeads = True
.ColumnWidths = "50;60;50;65;0;0;0;0;0;0;0;0;0;0;0"
.RowSource = Sheet1.Range("A2:O" & lastrow).Address(, , , True)
End With
I need to update column D of each row if the item is selected in the Listbox and have made a little progress, I've got this working, sort of, but it only updates the row for the first selected item and doesn't loop through them all of someone can help? The code I have so far is here;
Dim rngSearch As Range
Dim rngFound As Range
Dim i As Long
CheckedCalendarFrm.Show
Set rngSearch = Sheet1.Range("B2:B25")
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Set rngFound = rngSearch.Find(what:=.List(i, 1), LookIn:=xlFormulas, lookat:=xlWhole, MatchCase:=False)
If Not rngFound Is Nothing Then
rngFound(1, 3).Value = TextCheckDate
End If
End If
Next i
End With
Also posted here: https://www.mrexcel.com/forum/excel-questions/990715-update-column-selected-items-multi-select-listbox.html
Dim lastrow As Long
With Sheet1
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With Me.ListBox1
.ColumnCount = 15
.ColumnHeads = True
.ColumnWidths = "50;60;50;65;0;0;0;0;0;0;0;0;0;0;0"
.RowSource = Sheet1.Range("A2:O" & lastrow).Address(, , , True)
End With
I need to update column D of each row if the item is selected in the Listbox and have made a little progress, I've got this working, sort of, but it only updates the row for the first selected item and doesn't loop through them all of someone can help? The code I have so far is here;
Dim rngSearch As Range
Dim rngFound As Range
Dim i As Long
CheckedCalendarFrm.Show
Set rngSearch = Sheet1.Range("B2:B25")
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Set rngFound = rngSearch.Find(what:=.List(i, 1), LookIn:=xlFormulas, lookat:=xlWhole, MatchCase:=False)
If Not rngFound Is Nothing Then
rngFound(1, 3).Value = TextCheckDate
End If
End If
Next i
End With
Also posted here: https://www.mrexcel.com/forum/excel-questions/990715-update-column-selected-items-multi-select-listbox.html