I'm trying to code a routine to add records from a range on the worksheet SR to a listbox on a form. I want the record in the listbox to be made up of the values from a few cells in each row.
I'm getting a type mismatch on the ResultString line. I'm sure it's something simple, but I'm not seeing how what I've written is different from the usual suggestions.
Thanks in advance!
With SR
LastRow = .Cells(.Rows.count, "A").End(xlUp).Row
End With
Dim Rng As Range
Dim Row As Range
Dim ResultString As String
Set Rng = Range("A2:AC" & LastRow)
For Each Row In Rng.Rows
With SR
ResultString = .Cells(Row, 1).Value & " - " & .Cells(Row, 2).Value & " - " & .Cells(Row, 3).Value & " - " & .Cells(Row, 9).Value & " - " & .Cells(Row, 25).Value
End With
Me.lstResults.AddItem ResultString
Next Row
.Cells(Row, 1)you would need a numerical index rather than a range object (which is whatRowis). Perhaps you meanRow.Cells(1)although in that case theWithconstruct is superfluous.