loop through combobox items

RAYLWARD102

Well-known Member
Joined
May 27, 2010
Messages
529
Didn't get any feedback on this yesterday.
I'm trying to loop through some items in combobox vs item names in a range.
It works properly and makes the adjustments to the first item found in the range, but it doesn't adjust any of the other cells in the range. I msgboxed the combobox15.text in the loop to see if it was switching between the items in the combobox; and found that it wasn't. It only does the first item. How should I fix this? Do I need to change the list index in the loop to make the items change? Any help would be appreciated.

Code:
Private Sub CommandButton37_Click()
Dim param As Worksheet
    Set param = Worksheets("control")
Dim ques1 As String
    ques1 = ""
    ques1 = Application.InputBox("Enter character(s)to be removed from data")
Dim ques2 As String
    ques2 = ""
    ques2 = Application.InputBox("Enter character(s)to replace with")
Dim cell As Range
[COLOR=Magenta]Dim iCBo As Integer[/COLOR]
Dim iTe As Worksheet
    Set iTe = Worksheets(ComboBox2.Value)

If ques1 = "False" Then Exit Sub
If MsgBox("Are you sure you want to replace " & ques1 & " with " & ques2, vbYesNo) = vbNo Then
    'no
Else:
   [COLOR=Magenta] For iCBo = 0 To ComboBox15.ListCount ' - 1[/COLOR]
        For Each cell In iTe.Range(ComboBox3.Value & TextBox1.Value & ":" & ComboBox3.Value & TextBox2.Value).Cells
            If iTe.Range(ComboBox11.Value & cell.Row).Value <> 2 Then GoTo lynnloop
               [COLOR=Magenta] MsgBox ComboBox15.Text[/COLOR]
                If cell.Text <>[COLOR=Magenta] ComboBox15.Text [/COLOR]Then GoTo lynnloop
                    cell.Value = Replace(cell.Value, ques1, ques2)
                    cell.Value = Trim(cell.Value)
                    iTe.Range(ComboBox11.Value & cell.Row).Value = ""
lynnloop:
        Next cell
    Next iCBo
End If
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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