ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,699
- Office Version
- 2007
- Platform
- Windows
Hi,
Below is the code in use.
I would like to select an item from the ComboBox & once selected it should then populate TextBoxFind.
The ComboBox should be populated from my Worksheet called POSTAGE in column B9:B
Currently when i select the drop down on the ComboBox i see a RTE 1004,when i debug this line is in yellow.
LastRow = Worksheets("POSTAGE").Range(“C” & Rows.Count).End(xlUp).Row
But i dont see the reason why,please could you also check the code for both the ComboBox supplied.
Thanks
Below is the code in use.
I would like to select an item from the ComboBox & once selected it should then populate TextBoxFind.
The ComboBox should be populated from my Worksheet called POSTAGE in column B9:B
Currently when i select the drop down on the ComboBox i see a RTE 1004,when i debug this line is in yellow.
LastRow = Worksheets("POSTAGE").Range(“C” & Rows.Count).End(xlUp).Row
But i dont see the reason why,please could you also check the code for both the ComboBox supplied.
Thanks
Code:
Private Sub CloseUserForm_Click()
Unload SearchAndFindPostage
End Sub
Private Sub ComboBox1_DropButtonClick()
Dim i As Long, LastRow As Long
LastRow = Worksheets("POSTAGE").Range(“C” & Rows.Count).End(xlUp).Row
If Me.ComboBox1.ListCount = 0 Then
For i = 3 To LastRow
Me.ComboBox1.AddItem Sheets(“POSTAGE”).Cells(i, “C”).Value
Next i
End If
End Sub
Private Sub ComboBox1_Change()
Dim i As Long, LastRow As Long
LastRow = Sheets(“POSTAGE”).Range(“C” & Rows.Count).End(xlUp).Row
For i = 3 To LastRow
If Sheets(“POSTAGE”).Cells(i, “C”).Value = (Me.ComboBox1) Or _
Sheets(“POSTAGE”).Cells(i, “C”).Value = Val(Me.ComboBox1) Then
Me.TextBoxFind = Sheets(“POSTAGE”).Cells(i, “C”).Value
End If
Next
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub ReplaceVehicleButton_Click()
Dim lRow As Long, rng As Range, f As Range
With Worksheets("POSTAGE")
lRow = .Cells(.Rows.Count, 3).End(xlUp).Row
Set rng = .Range("C9:C" & lRow)
Set f = rng.Find(TextBoxFind.Text, , xlValues, xlWhole)
If f Is Nothing Then
MsgBox TextBoxFind.Text & " Was Not Found, Please Try Again", vbCritical, "UPDATE VEHICLE INFO MESSAGE"
TextBoxFind.SetFocus
Else
rng.Replace What:=TextBoxFind.Text, Replacement:=TextBoxReplace.Text, LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False
MsgBox "WORKSHEET UPDATED SUCCESSFULLY", vbInformation, "UPDATE VEHICLE INFO MESSAGE"
End If
TextBoxFind.Value = ""
TextBoxReplace.Value = ""
End With
End Sub
Private Sub TextBoxFind_Change()
TextBoxFind = UCase(TextBoxFind)
End Sub