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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Welcome to the Board!

You just need to use the correct range reference:

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

Hope that helps,

Smitty
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,037
Members
448,543
Latest member
MartinLarkin

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