VBA to find next blank row based on userform entry

crburke92

Board Regular
Joined
Feb 5, 2019
Messages
71
Hey All,

I currently have a userform with 3 inputs (DevID, DevSel and LocSel). The Idea is to copy a template sheet based off combobox DevSel, and rename the sheet based on the DevID text box. The issue I have is I have combobox LocSel poplated with the defined range "Headers" (A1:A20) and want to use V&HLooup, or HLookup & Match to return first blank cell under the matched LocSel header, and make it equal DevID.

VBA Code:
Private Sub Execute_Btn_Click()
Dim DevID As String
Dim Headers as Range

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,0), False), False) = DevID
End Select

In the Debugger, LocSel and DevID are populating with the correct information. based on my box selections, but I keep getting Runtime Error1004 - Unable to get the Match property of the worksheetfunction class. Any help would be appreciated!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You could explain with images and examples what you have in your textbox and combobox controls, what you want to search, in which sheet you want to search and what the result would be.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,680
Members
449,116
Latest member
HypnoFant

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