How to use a cell value for ActiveWorkbook.CustomViews(****)

dorokhin

New Member
Joined
Jul 23, 2007
Messages
3
Hi there, I'm having some trouble with a workbook I'm trying to make. I want the user to be able to put in a state into a cell, click a button, and come up with a report view that has been tailored to their selection.

In my VBA code I have a line:
ActiveWorkbook.CustomViews("NY2008").Show

Ideally, I'd want it to be something like:
ActiveWorkbook.CustomViews(A1).Show

The user would specify "NY2008" into cell A1.

However, the formula doesn't seem to work with this.

Is it possible to have the ActiveWorkbook.CustomViews() command pull the name of the custom view from a cell some other way?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Welcome to the Board!

You just need to use the correct range reference:

Code:
ActiveWorkbook.CustomViews(Range("A1").Value).Show

Hope that helps,

Smitty
 

Forum statistics

Threads
1,181,659
Messages
5,931,273
Members
436,786
Latest member
Deniel

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
Top