Hi all,
I recently posted this thread
This previous query was solved. I now have another query.
On the same userform as described in the thread linked above I have another method of searching my worksheet that provides the user a faster return on their query providing they know the title's SKU number.
Originally I had the following code in place, designed to only inform the user which row to title was located on so that they could manually navigate there. Now that the combobox query has been solved from my last thread, I'd like to have this SKU search textbox function the same as the combobox, while still retaining some key aspects of the original code; namely the error reporting and success notification.
Original code
Private Sub skuButton1_Click()
'This sub will search column C for the SKU number the user has entered into the sku search box
Dim skuCell As Range
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("Live Tracker").Range("skuCell")
Set skuCell = rng.Find(What:=skuSearch.Value, _
After:=rng.Cells(1), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
If skuCell Is Nothing Then
MsgBox "SKU '" & skuSearch & "' not found." <<< I would like to keep this
Else
If Not IsEmpty(skuCell) Then
MsgBox "Your SKU has been found on Row: " & skuCell.Row <<< and this
End If
End If
End Sub
The new code for populating the eight development stage textboxes is copied and modified from the previous thread's solution.
Private Sub skuSearch_AfterUpdate() <<< changed to AfterUpdate
With Worksheets("Data")
.Range("K1").Value = Me.skuSearch.Value <<< changed the ranges
.Range("K2:K9").Calculate
Me.podQATextBox = .Range("K2").Value
Me.playlistQATextBox = .Range("K3").Value
Me.firstQATextBox = .Range("K4").Value
Me.fixes1TextBox = .Range("K5").Value
Me.premasterTextBox = .Range("K6").Value
Me.fixes2TextBox = .Range("K7").Value
Me.shippingTextBox = .Range("K8").Value
Me.testDiscTextBox = .Range("K9").Value
End With
End Sub
My query is, how can I merge these two chunks of code so that the search bar reports a "SKU not found" when; A) the Search command button is selected while the search textbox is empty. B) when the SKU is entered incorrectly.
In addition, when the SKU is entered correctly, a message to say it has been found (but doesn't need to report the row anymore though) and then populate the development stage textboxes with the relevant values from the Data worksheet (like the combobox from the other thread does).
If there's any additional information you may need in order to help with this query, please ask.
Many thanks in advance!
A Grace
Bookmarks