Thread: [Solved] UserForm VLookUp
View Single Post
 
Old 03-01-2019, 03:16 PM
ChettoDust ChettoDust is offline Windows XP Office 2010
Novice
 
Join Date: Mar 2019
Posts: 4
ChettoDust is on a distinguished road
Default UserForm VLookUp

Hello all,

I have created a userform to pull data from a worksheet to make changes then add the new data back into the worksheet. I am getting an 'object required error' on the second line
(If WorksheetFunction). My goal is to have tool makers be able to add there info into the form and hit save so that the new information is added back into the worksheet and also the information the tool maker added be saved to a second worksheet. My code is below:

The sheet I'm pulling data from is named "SOL"
The sheet I want all the new data to go back into "SOL" then only the data that the tool maker entered go to "Tool Room"

The only info the tool maker is adding is: Tool Maker, Tool Number, Hours, Date Completed
Code:
 
Private Sub Shop_TB2_AfterUpdate()
If WorksheetFunction.CountIf(SOL.Range("A8:A"), Me.Shop_TB2.Value) = 0 Then
MsgBox "Incorrect Order Number"
Me.Shop_TB2.Value = ""
Exit Sub
End If
With Me
.Date_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 2, 0)
.Name_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 3, 0)
.Area_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 4, 0)
.Account_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 5, 0)
.PartNum_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 6, 0)
.PartName_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 7, 0)
.Quantity_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 8, 0)
.RequestedDate_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 9, 0)
.Complete_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 10, 0)
.Build_TB2 = Application.WorksheetFunction.VLookup(CLng(Me.Shop_TB2), SOL.Range("Lookup"), 11, 0)
End With
End Sub

Last edited by Pecoflyer; 03-02-2019 at 01:30 AM. Reason: Moved to correct sub forum
Reply With Quote