VB Code to select multiple named ranges

HSA

New Member
Joined
Apr 3, 2002
Messages
8
I have a spreadsheet with up to 30 named ranges. I want to select, set the print area and preview only those ranges that have data in a specific cell. I need this as a total report and not the ranges one at a time.

I hope somebody can help.

Liz
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi Liz,

Unless you write to another "Report" sheet, you probably won't be able to build a report of discontinuous ranges.

One workaround -- Copy the ranges as pictures and paste into a report.

Select the range. Hold down the shift key and pull down the Edit menu -- select Copy Picture. Do this for the rest of the named ranges and create your report.

You are copying screen shots here, so if the data changes, the picture will not update.

HTH,
Jay
 
Upvote 0
Thanks,

I can set the print area for discontinuous ranges by selecting the first named range from the name box and then holding down the Ctrl Key selecting the next name range that is required. I really wanted to automate this procedure as it is prone to user error.

Liz
 
Upvote 0
Hi Liz


Not too sure if this could work in your situation, but have a look into "Report Manager" and "Custom Views" in the Excel Help. These 2 features work hand-in-hand and are ideal for Printing reports.
 
Upvote 0
Hi Liz,

In addition to Dave's suggestions, you can select your ranges in code.

I named two discontinuous ranges, First and Second, and then selected them with

Range("First, Second").Select

I haven't yet solved reading them into an array and selecting the array, but this may suffice. The 30 ranges will make for a long statement, but will enable you to eliminate user error.

Possibly a loop with the Choose function...hmmm...

Bye,
Jay
 
Upvote 0

Forum statistics

Threads
1,214,416
Messages
6,119,384
Members
448,889
Latest member
TS_711

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