简体   繁体   中英

MS Excel dynamic print area

I wish to create a dynamic Print_Area in Excel 2010 which will consist of two cell ranges.

For example the first cell range is A1:J50 and the second range is A100:J150 . These should print out on two pages, ignoring the cells that come in between these two ranges.

The four cells shown in the above example ranges should be dynamic, and not hard coded as simple Print_Area ranges. Therefore in my worksheet I used cells AA1 , AB1 , AC1 and AD1 to store values "A1" , "J50" , "A100" and "J150" respectively.

(The cells AA1, AB1, AC1 and AD1 actually use formulas to determine what cell address will be used, but for this question lets just assume the values are set as above).

I then used the Name Manager and entered the following formula under Print_Area:

=INDIRECT(Sheet1!$AA$1):INDIRECT(Sheet1!$AB$1);INDIRECT(Sheet1!$AC$1):INDIRECT(Sheet1!$AD$1)

The result of this formula is exactly what I need, and it actually works the first time I print the ranges. However once I did that, Excel automatically substitutes the formula with the actual cell range that was calculated. So when I check the Print_Area in the Name Manager after printing once, it contains something like:

=Sheet1!$A$1:$J$50,Sheet1!$A$100:$J$150

Is there a way to prevent the Print_Area from converting my formula to calculated values, and instead using the formula every time I print? I would like to not use macros if at all possible (if not, I'll try macros too)

I tested this and it seemed to work.

Create a new name called Test and set its value to (Note that I used a comma rather than the semicolon you had. I have US language set)

=INDIRECT(Sheet1!$AA$1):INDIRECT(Sheet1!$AA$2),INDIRECT(Sheet1!$AA$3):INDIRECT(Sheet1!$AA$4)  

Set your Print_Area name to

=TEST

Good luck!

EDIT

The above works for me, but it appears unnecessary. I just tried to replicate the problem, and was unable. When I have the Print_Area set to the formula with INDIRECT it does not replace after printing.

See this linked file. https://www.dropbox.com/s/pgm0iv19u6igdm5/Book1.xlsx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM