Match and find entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a listbox in a userform the user makes his multiple selections, I need
the macro to search the range database to find the matching row and place
"Paid" in it there. The following code assumes:
the entries in your listbox correspond to the rows of the range Database,
but that isn't correct they don't correspond. So can anyone show me how to
fix this. Tom said to record a macro using the EDIT>FIND method but i
couldn't make that work. Thank you so much for you help!

'Set sh = Worksheets("ProduceData")
'Dim rng As Range
'Set rng = sh.Range("Database").Columns(1).Cells
'Dim i As Long
'Dim rw As Long
'
'For i = 0 To lstData.ListCount - 1
' If lstData.Selected(i) Then
' rw = rng(i + 1).Row
' sh.Cells(rw, "ag").Value = "Paid"
' End If
'Next
 
Set sh = Worksheets("ProduceData")
Dim rng As Range
Set rng = sh.Range("Database").Columns(1).Cells
Dim i As Long
Dim rw As Long

For i = 0 To lstData.ListCount - 1
If lstData.Selected(i) Then
Set rng = Nothig
If Not rng Is Nothing Then rng.Value = "Paid"
End If
Next

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top