input box in formula

kenpcli

Board Regular
Joined
Oct 24, 2017
Messages
129
Hi Everyone

I need a script to replace the '08-05 TO 08-11' with an input box. I need the user to define which pay period they are wanting to lookup and then place that formula into cell D2.

=IFERROR(VLOOKUP(C2,'08-05 TO 08-11'!$C:$Q,2,0),"")

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
Code:
   Dim Sht As String
   Sht = InputBox("Please enter the sheet name")
   Range("D2").Formula = "=IFERROR(VLOOKUP(C2,'" & Sht & "'!$C:$Q,2,0),"""")"
 
Upvote 0
glad to help & thanks for the feedback
 
Upvote 0
I need a script to replace the '08-05 TO 08-11' with an input box. I need the user to define which pay period they are wanting to lookup and then place that formula into cell D2.

=IFERROR(VLOOKUP(C2,'08-05 TO 08-11'!$C:$Q,2,0),"")
Instead of an InputBox, you could devote one cell somewhere in your workbook to the sheet name and then bundle that into your formula via the INDIRECT function. For example, let's say you devoted cell B2 on the same sheet your formula is on (otherwise you would have to include a sheet name when referencing cell B2 on that sheet). Then your formula would become...

=IFERROR(VLOOKUP(C2,INDIRECT("'"&B2&"'!$C:$Q"),2,0),"")
 
Upvote 0

Forum statistics

Threads
1,225,757
Messages
6,186,848
Members
453,379
Latest member
gabriellegonzalez

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