![]() |
Match and find entry
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 EDITFIND 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 -- Though daily learning, I LOVE EXCEL! Jennifer |
Match and find entry
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) "Jennifer" wrote in message ... 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 EDITFIND 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 -- Though daily learning, I LOVE EXCEL! Jennifer |
All times are GMT +1. The time now is 03:58 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com