RAYLWARD102
Well-known Member
- Joined
- May 27, 2010
- Messages
- 529
Not sure how to go about this. I populated combobox15 with some items in some code that isn't posted. I'd like the user to be able to make a group edit to those items in the cbobox15. Because the items are unique; I thought I would run each cbobox item against the range and change accordingly as written below. The only thing I could use some help with, would be how I address comparing the combobox items. Pretty sure I'm handling it wrong and could use some direction.
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 items As ComboBox.Item[/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:
For Each [COLOR=Magenta]items In ComboBox15.List[/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
If cell.Text <>[COLOR=Magenta] items[/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
[COLOR=Magenta]Next Item[/COLOR]
End If
End Sub
Last edited: