Auto populate TextBox on UserForm using the same type formula from Worksheet?

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
485
Office Version
  1. 365
Platform
  1. Windows
Hope I can explain this properly.

I have a formula in column E that matches data in column C and displays a hyperlinked name based on that data. Looks like this:

JE02.jpg


Now I've created a UserForm to make data entry on the main sheet easier. I'd like to add the same auto populate feature found in column E to the UserForm "Field Manager" text box. So, when I type data in the "Sub/Lot Code" text box I need the "Field Manager" text box to auto populate based on that data. The "Field Manager" text box is named FieldManagerReturn.

JE01.jpg


I'm not sure where the code that does the matching would reside. Perhaps with the actual Form?

VBA Code:
Option Explicit
Private Sub cmdReset_Click()
    Call Reset
End Sub
Private Sub cmdSave_Click()
    Call Submit
    Call Reset
End Sub
Private Sub GarageHandling_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        If KeyCode = 13 Then
             Submit
        End If
        If KeyCode = 13 Then
             Reset
        End If
End Sub
Private Sub Frame1_Click()
End Sub
Private Sub txtID_Change()
End Sub
Private Sub Frame2_Click()
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Initialize()
    Call Reset
End Sub
Private Sub userform_terminate()

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Sheets("Database").Visible = True
    Sheets("Database").Select

    Dim WorkRange As Range
    Dim Cell As Range
    Set WorkRange = ActiveSheet.UsedRange
    For Each Cell In WorkRange
        If Cell.Locked = False Then Cell.ClearContents
    Next Cell

    Sheets("Database").Visible = False
    Sheets("Calendar").Select
    
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

End Sub
Private Sub CloseButton_Click()
  Unload Me
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I need to revisit this. Here's the code I've been using successfully:

VBA Code:
Private Sub SubLotCode_Change()

     If Me.SubLotCode Like "1076*" Then
        Me.SubdivisionReturn = "RHR - River Hill Ridge"
        Me.FieldManagerReturn = "Mike Zaski"
    ElseIf Me.SubLotCode Like "1079*" Then
        Me.SubdivisionReturn = "BME - Bald Mountain Estates"
        Me.FieldManagerReturn = "Scott Bennett"
    ElseIf Me.SubLotCode Like "1080*" Then
        Me.SubdivisionReturn = "MP - Merrill Park"
        Me.FieldManagerReturn = "Brian Curry"
    ElseIf Me.SubLotCode Like "1081*" Then
        Me.SubdivisionReturn = "OBL - Oberlin"
        Me.FieldManagerReturn = "Kyle Trombley"
    ElseIf Me.SubLotCode Like "1083*" Then
        Me.SubdivisionReturn = "BMS - Bald Mountain Signature"
        Me.FieldManagerReturn = "Scott Bennett"
    ElseIf Me.SubLotCode Like "1084*" Then
        Me.SubdivisionReturn = "BMC - Bald Mountain Cottages"
        Me.FieldManagerReturn = "Scott Bennett"
    ElseIf Me.SubLotCode Like "1085*" Then
        Me.SubdivisionReturn = "EON - Enclaves of Northville"
        Me.FieldManagerReturn = "Davor Zubac"
    ElseIf Me.SubLotCode Like "1086*" Then
        Me.SubdivisionReturn = "FE - Forest Edge"
        Me.FieldManagerReturn = "Davor Zubac"
    ElseIf Me.SubLotCode Like "1087*" Then
        Me.SubdivisionReturn = "GV - Grandview Estates"
        Me.FieldManagerReturn = "Mike Zaski"
    ElseIf Me.SubLotCode Like "1089*" Then
        Me.SubdivisionReturn = "IP - Inglewood Park"
        Me.FieldManagerReturn = "Nicholas Surma"
    ElseIf Me.SubLotCode Like "1090*" Then
        Me.SubdivisionReturn = "DIX - Dixon Meadows"
        Me.FieldManagerReturn = "Kevin DeMeere"
    ElseIf Me.SubLotCode Like "1091*" Then
        Me.SubdivisionReturn = "HW - Huntington Woods"
        Me.FieldManagerReturn = "Nicholas Surma"
    ElseIf Me.SubLotCode Like "1092*" Then
        Me.SubdivisionReturn = "RP - Rathmor Park"
        Me.FieldManagerReturn = "Ali Taha"
    ElseIf Me.SubLotCode Like "1093*" Then
        Me.SubdivisionReturn = "BH - Beacon Hill"
        Me.FieldManagerReturn = "Adam Goldberg"
    ElseIf Me.SubLotCode Like "1094*" Then
        Me.SubdivisionReturn = "NM - Nankin Mills"
        Me.FieldManagerReturn = "Adam Goldberg"
    ElseIf Me.SubLotCode Like "1095*" Then
        Me.SubdivisionReturn = "LOC - The Landings of Canton"
        Me.FieldManagerReturn = "Mike Zaski"
    ElseIf Me.SubLotCode Like "1096*" Then
        Me.SubdivisionReturn = "VNS - Villas at North Sky"
        Me.FieldManagerReturn = "Eric Henderson"
    ElseIf Me.SubLotCode Like "1097*" Then
        Me.SubdivisionReturn = "NS - North Sky"
        Me.FieldManagerReturn = "Eric Henderson"
    ElseIf Me.SubLotCode Like "1098*" Then
        Me.SubdivisionReturn = "VAI - Villas at Inglewood Park"
        Me.FieldManagerReturn = "Nicholas Surma"
    ElseIf Me.SubLotCode Like "1099*" Then
        Me.SubdivisionReturn = "WB - Westbury"
        Me.FieldManagerReturn = "Mike Zaski"
    ElseIf Me.SubLotCode Like "1100*" Then
        Me.SubdivisionReturn = "TB - Twin Beach"
        Me.FieldManagerReturn = "Brian Curry"
    ElseIf Me.SubLotCode Like "1101*" Then
        Me.SubdivisionReturn = "WEP - Wellington Place"
        Me.FieldManagerReturn = "Wally Hedemark"
    ElseIf Me.SubLotCode Like "1102*" Then
        Me.SubdivisionReturn = "PNV - Pine Vista"
        Me.FieldManagerReturn = "Garrett Vermeersch"
    ElseIf Me.SubLotCode Like "1103*" Then
        Me.SubdivisionReturn = "SUM - Sumerlyn"
        Me.FieldManagerReturn = "Jason Poag"
    ElseIf Me.SubLotCode Like "1104*" Then
        Me.SubdivisionReturn = "WTP - West Trail Preserve"
        Me.FieldManagerReturn = "Adam Goldberg"
    ElseIf Me.SubLotCode Like "1105*" Then
        Me.SubdivisionReturn = "EAH - Estates at Hutsfield"
        Me.FieldManagerReturn = "Davor Zubac"
    ElseIf Me.SubLotCode Like "1106M*" Then
        Me.SubdivisionReturn = "EP - Emerson Park"
        Me.FieldManagerReturn = "Tim Clemens"
    ElseIf Me.SubLotCode Like "1107*" Then
        Me.SubdivisionReturn = "GM - Gregory Meadows"
        Me.FieldManagerReturn = "Chadd Willson"
    ElseIf Me.SubLotCode Like "1108*" Then
        Me.SubdivisionReturn = "EBV - Estates at Bella Vista"
        Me.FieldManagerReturn = "Shaun Jaward"
    ElseIf Me.SubLotCode Like "1109M*" Then
        Me.SubdivisionReturn = "VBV - Villas of Bella Vista"
        Me.FieldManagerReturn = "Shaun Jaward"
    ElseIf Me.SubLotCode Like "1110*" Then
        Me.SubdivisionReturn = "PG - Pittsfield Glen"
        Me.FieldManagerReturn = "Eric Henderson"
    ElseIf Me.SubLotCode Like "1111M*" Then
        Me.SubdivisionReturn = "TMS - Townes at Mill Street"
        Me.FieldManagerReturn = "Mike Zaski"
    ElseIf Me.SubLotCode Like "1112M*" Then
        Me.SubdivisionReturn = "VOS - Villas of Stonebrook"
        Me.FieldManagerReturn = "Kyle Trombley"
    ElseIf Me.SubLotCode Like "1113*" Then
        Me.SubdivisionReturn = "BW - Beachwood"
        Me.FieldManagerReturn = "Adam Goldberg"
    ElseIf Me.SubLotCode Like "1114M*" Then
        Me.SubdivisionReturn = "TPG - Townes at Pittsfield Glen"
        Me.FieldManagerReturn = "Eric Henderson"
    ElseIf Me.SubLotCode Like "1115M*" Then
        Me.SubdivisionReturn = "BRK - Breckenridge"
        Me.FieldManagerReturn = "Scott Bennett"
    ElseIf Me.SubLotCode Like "1116*" Then
        Me.SubdivisionReturn = "WH - Woodland Hills"
        Me.FieldManagerReturn = "Kirk Peffers"
    ElseIf Me.SubLotCode Like "1117*" Then
        Me.SubdivisionReturn = "HER - Heritage Woods"
        Me.FieldManagerReturn = "Kyle Trombley"
    ElseIf Me.SubLotCode Like "1118*" Then
        Me.SubdivisionReturn = "HIL - Hillcrest"
        Me.FieldManagerReturn = "Chadd Willson"
    ElseIf Me.SubLotCode Like "1119*" Then
        Me.SubdivisionReturn = "AND - Andover Forest"
        Me.FieldManagerReturn = "Mike Zaski"
    ElseIf Me.SubLotCode Like "1120*" Then
        Me.SubdivisionReturn = "BSH - Bluffs at Spring Hill"
        Me.FieldManagerReturn = "Davor Zubac"
    ElseIf Me.SubLotCode Like "1121M*" Then
        Me.SubdivisionReturn = "GRH - The Groves at Rochester Hills"
        Me.FieldManagerReturn = "Jamie Celestini"
    ElseIf Me.SubLotCode Like "1122M*" Then
        Me.SubdivisionReturn = "WBP - Woodbridge Park"
        Me.FieldManagerReturn = "Tim Clemens"
    ElseIf Me.SubLotCode Like "1123*" Then
        Me.SubdivisionReturn = "ARB - Arbor Glen"
        Me.FieldManagerReturn = "Mike Zaski"
    ElseIf Me.SubLotCode Like "1124*" Then
        Me.SubdivisionReturn = "FW - Fuhrmann Woods"
        Me.FieldManagerReturn = "Shaun Jaward"
    ElseIf Me.SubLotCode Like "1125*" Then
        Me.SubdivisionReturn = "AO - Arbor Oaks"
        Me.FieldManagerReturn = "Shaun Jaward"
    ElseIf Me.SubLotCode Like "1126*" Then
        Me.SubdivisionReturn = "FS - Fieldstone"
        Me.FieldManagerReturn = "Jacob Johnson"
    ElseIf Me.SubLotCode Like "1127*" Then
        Me.SubdivisionReturn = "GVS - Grandview Estates South"
        Me.FieldManagerReturn = "Mike McGraw"
    ElseIf Me.SubLotCode Like "1128*" Then
        Me.SubdivisionReturn = "BP - Beacon Pointe"
        Me.FieldManagerReturn = "Jamie Celestini"
    Else
        Me.SubdivisionReturn = ""
        Me.FieldManagerReturn = ""
    End If

End Sub

The issue is adding new SubLotCodes is a pain. I need the same match capability that the code above provides but I want the SubLotCodes and names on a sheet that is much easier to add to. That way I don't have to edit the code every time I want to add a new name.

I already have a sheet called DataCenter that has all the information:

NewMatch.png


The columns I want to work with are B, D, and H.
 
Upvote 0
Maybe something like this?

VBA Code:
Private Sub SubLotCode_Change()

     If Me.SubLotCode Like "DataCenter!D:D" Then
        Me.SubdivisionReturn = "DataCenter!B:B"
        Me.FieldManagerReturn = "DataCenter!H:H"
    Else
        Me.SubdivisionReturn = ""
        Me.FieldManagerReturn = ""
    End If

End Sub
 
Upvote 0
I think this thread does some of what I want to do:

 
Upvote 0

Forum statistics

Threads
1,224,830
Messages
6,181,227
Members
453,025
Latest member
Hannah_Pham93

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top