HLookup & Match driven by UserForm inputs

crburke92

Board Regular
Joined
Feb 5, 2019
Messages
71
Hello,

Hoping I'm pretty close and there's a simple solution. I have a Userform that has 3 inputs. A textbox (DevID), and 2 Comboboxes (DevSel & LocSel). The idea is to name a new sheet using DevID, The sheet to copy is a hidden worksheet selected via DevSel. This portion works fine.

The part I'm struggling with is using a HLookup & Match to find the first blank cell underneath the matched value in LocSel and make the value DevID. What I currently have is:

VBA Code:
Private Sub Close_Btn_Click()
UFInfo.Hide
End Sub

Private Sub Execute_Btn_Click()
Dim DevID As String

Select Case DevSel
    Case "HVBKR"
       Sheets("HVCIRCUITBREAKER_TEMP").Visible = True
            Sheets("HVCIRCUITBREAKER_TEMP").Copy After:=Sheets("Master")
                Sheets("HVCIRCUITBREAKER_TEMP").Visible = False
                    ActiveSheet.Name = Me.DevID.Text
WorksheetFunction.HLookup(LocSel, Range("Headers"), WorksheetFunction.Match(LocSel, Range("Headers").End(xlUp).Offset(1), False), False) = DevID
End Select

Unload Me
Sheets("Master").Activate

End Sub

Private Sub UserForm_Initialize()
Dim Cell As Range
For Each Cell In Range("Headers")
    UFInfo.LocSel.AddItem (Cell.Value)
Next Cell

For Each Cell In Range("DevList")
    UFInfo.DevSel.AddItem (Cell.Value)
Next Cell
End Sub

Combo boxes fill from named ranges which also works fine. Currently I'm getting Run time error '1004' Unable to get the Match property of the WorksheetFunction class. I'm assuming I'm not referencing the Combobox/Textbox selections properly/need to dim them properly?

Thanks in advance!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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