I am pretty new to VBA and have learned most of what I know on this site. So I figured if I had a question I couldn't find the answer to this would be the site to come to. I am trying to create a sheet that is a database of parts. I have created a user form that lets you fill in the different information and then prints it. I am now trying to make the form look up all the information on a part if it already exists and print it in the correct text box. The problem I am having is that the Match function won't work with numbers and all my part numbers are only numbers. If I try having a part number named "PartPart" for instance it will work though. Here is my code below. Between the ** is where the error starts.
Code:
Sub GWNumberTextBox_AfterUpdate()
On Error GoTo 0
Dim CusNameRange As Range
Dim ThreeCusNameRange As Range
Dim GWnumber As String
Dim ThreeGW As String
Dim SheetRange As Range
Dim GWNumRange As Range
Set SheetRange = Worksheets("Parts").Range("$A$8:$X$1000")
Set GWNumRange = Worksheets("Parts").Range("$A$1:$A$4")
Set CusNameRange = Worksheets("List Contents").Range("$E$12:$F$770")
Set ThreeCusNameRange = Worksheets("List Contents").Range("$F$12:$F$770")
GWnumber = GWNumberTextBox.Value
ThreeGW = Left(GWnumber, 3)
On Error Resume Next
CusNameTextBox.Value = Application.WorksheetFunction.Index(CusNameRange,
Application.WorksheetFunction.Match(ThreeGW, ThreeCusNameRange, False), 1)
*CusPartNumTextBox.Value = Application.WorksheetFunction.Index(SheetRange, Application.WorksheetFunction.Match(GWnumber, GWNumRange, 0), 2)*
CusNameTextBox.Value = Application.WorksheetFunction.Index(SheetRange, Application.WorksheetFunction.Match(GWnumber, GWNumRange, 0), 6)
DivisionComboBox.Value = Application.WorksheetFunction.Index(SheetRange, Application.WorksheetFunction.Match(GWnumber, GWNumRange, 0), 8)
PartStatusComboBox.Value = Application.WorksheetFunction.Index(SheetRange, Application.WorksheetFunction.Match(GWnumber, GWNumRange, 0), 9)
MoldStatusComboBox.Value = Application.WorksheetFunction.Index(SheetRange, Application.WorksheetFunction.Match(GWnumber, GWNumRange, 0), 10)
MoldLocationComboBox.Value = Application.WorksheetFunction.Index(SheetRange, Application.WorksheetFunction.Match(GWnumber, GWNumRange, 0), 11)
End Sub