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.
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