[VBA] "Pick" a Worksheet Tab and save it to a variable

PeteWright

Active Member
Joined
Dec 20, 2020
Messages
492
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi all,
I've been deeply searching for this, but couldn't find an answer anywhere.
There is like a gazillion of topics, but none of the posted codes work for me.

So what I need is a user input (like prompt or something - or just a Mouse Pointer) to "pick" a Worksheet Tab from the bottom tabs and save it's reference to a variable.

The only thing that comes close which I found is the Application.InputBox "object" which unfortunately doesn't seem to handle all possible user inputs but a few (e.g. String, Boolean, Range) and can't cope with a selected tab.

This is one of my many code snippets which only gives me the error "Excel found a problem with one or more Formula References in this worksheet."
VBA Code:
Sub Zero()
   Debug.Print Application.InputBox("Select a Worksheet Tab", "Select Tab", , , , , , 8)
End Sub

Any ideas on this?
 
Break on Unhandled Errors is the default setting. So, unless the user changes this setting, you shouldn't have a problem.
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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