Hi,

I'm attempting to (probably butchering it..) create a bit of code as part of my userform. One of the first textboxes filled is the unique "project number".

I'm trying to add some code that when the user exits from this textbox, this value is used in a vlookup to see if the project number exists in an existing excel document.

IF true, I want to set the values of several other textboxes on the userform equal to other values in the excel document.

I hope that make sense? Basically --> If Project number exists in Range C2:C1500 on "ProjectRegister" excel sheet, then set textbox1 = ProjectRegister Value A etc

So far I have the following code which is not complete (it should check if the value exists in the range but no more). It also is currently coming back with Error 91 but I cannot solve that either. Any help would be greatly appreciated!!!!:

Private Sub TB3_Exit(ByVal Cancel As MSForms.ReturnBoolean)'Below for lookup in excel sheet


    
    Dim oXL As Excel.Application
    Dim oWB As Excel.Workbook
    Dim oSheet As Excel.Worksheet
    Dim oRng As Excel.Range
    Dim ExcelWasNotRunning As Boolean
    Dim WorkbookToWorkOn As String
    
    
'________________________________________


    'Specifiy File to Open
   WorkbookToWorkOn = "C:\Users\billy\Desktop\GEA.JOBBOARD.xlsm"
    'Check if excel is open or start new
    
        On Error Resume Next
        Set oXL = GetObject(, "Excel.Application")
        If Err Then
            ExcelWasNotRunning = True
            Set oXL = New Excel.Application
        End If
        
        On Error GoTo Err_Handler
        
'If you want to see the excel put "oXL.Visible = true" but it slows sh*t down


'open book


                Set oWB = oXL.Workbooks.Open(FileName:=WorkbookToWorkOn)
    
                Set wsht = ActiveWorkbook
                Set wksheet = wsht.Worksheets("ProjectRegister")
    
                If oXL.WorksheetFunction.VLookup(Me.TB3, oSheet("ProjectRegister").Range("C2:C1500"), 1, False) = True Then
                
'THIS IS WHERE I GOT TO BEFORE GETTING STUMPED

MsgBox oXL.WorksheetFunction.VLookup(Me.TB3, oSheet.Range("C2:C1500"), 1, False)
    
    End If
    
If ExcelWasNotRunning Then
oXL.Quit
End If


Set oRng = Nothing
Set oSheet = Nothing
Set oWB = Nothing
Set oXL = Nothing


Exit Sub


Err_Handler:
   MsgBox WorkbookToWorkOn & " caused a problem. " & Err.Description, vbCritical, _
           "Error: " & Err.Number
   If ExcelWasNotRunning Then
       oXL.Quit
   End If
End Sub