Combining Inputbox Types

sparky2205

Well-known Member
Joined
Feb 6, 2013
Messages
507
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I'm trying to come up with a solution to allow users either directly type an entry into an inputbox or alternatively select the entry from a list.
So something like:
VBA Code:
Set personnel = Application.InputBox("Type a name or select a name from column B", Type:=2+8)
But of course this won't work as Type 2 is a string and Type 8 is a range.
Am I missing something simple or is there a workaround I can use?

I also tried:
VBA Code:
If Not IsError(Application.InputBox("Select a name from column B", Type:=8)) Then
        Set personnel = Application.InputBox("Select a name from column B", Type:=8)
        Else:
        Set personnel = Application.InputBox("Enter a name", Type:=2)
End If
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I would replicate an input box with a modal userform, especially if "by list" you mean something like a listbox. However, I think your list is probably a range on a sheet. In that case, you could present either a userform or message box and get the desired method first. Or present 2 options on a sheet via option buttons.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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