combobox to find value using loop

Status
Not open for further replies.

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
204
Office Version
  1. 2010
Platform
  1. Windows
Hi i have userform with combobox 9 when you select combobox9 value it will show all the values into the each boxes and you can updated the textbox 19 value into sheet against the raw of the selected value in combobox9 however problem is if theres the same name e.g. twice same name in combobox9 it will only update the its 1st name on the raw and not the 2nd or even if there is 3 entry in sheet with same name.

names are in coloum C and textvalue is updated its name on coloum H however i need to loop the coloum H if it is already updated against its name then same name needs to updated which is in new raw.

below its the vba code i have so far but it it is till not working

VBA Code:
If Me.ComboBox9.Value <> "" Then

If VBA.CVar(Application.Match(VBA.CVar(Me.ComboBox9.Value), sh.Range("C:C"), 0)) = True Then

MsgBox "Record Not found for this PO-Number", vbCritical

Exit Sub

Else

i = Application.Match(VBA.CStr(Me.ComboBox9.Value), sh.Range("C:C"), 0)

End If

lCol = Me.ComboBox9.Value

Set findvalue2 = sh.Range("C:C").Find(What:=lCol, LookIn:=xlValues)

If Not findvalue2 Is Nothing Then

adr = findvalue2.Address

Do

If findvalue2.Offset(0, -1).Value = Me.TextBox19 Then

sh.Unprotect "1234"

findvalue2.Offset(0, 6).Value = Me.TextBox19.Value = ""

Exit Do

End If

Set findvalue2 = sh.Range("C:C").FindNext(findvalue2)

Loop While findvalue2.Address <> adr

Set findvalue2 = Nothing

End If
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Status
Not open for further replies.

Forum statistics

Threads
1,213,510
Messages
6,114,037
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top