简体   繁体   English

MS Excel动态打印区域

[英]MS Excel dynamic print area

I wish to create a dynamic Print_Area in Excel 2010 which will consist of two cell ranges. 我希望在Excel 2010中创建一个动态Print_Area,它将由两个单元格区域组成。

For example the first cell range is A1:J50 and the second range is A100:J150 . 例如,第一个单元格范围是A1:J50 ,第二个范围是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. 上面示例范围中显示的四个单元应该是动态的,而不是硬编码为简单的Print_Area范围。 Therefore in my worksheet I used cells AA1 , AB1 , AC1 and AD1 to store values "A1" , "J50" , "A100" and "J150" respectively. 因此,在我的工作表中,我使用了AA1AB1AC1AD1来分别存储值"A1""J50""A100""J150"

(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). (单元格AA1,AB1,AC1和AD1实际上使用公式来确定将使用哪个单元格地址,但是对于这个问题,我们仅假设值设置如上)。

I then used the Name Manager and entered the following formula under Print_Area: 然后,我使用名称管理器,并在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. 但是,一旦执行此操作,Excel就会自动将公式替换为所计算的实际单元格范围。 So when I check the Print_Area in the Name Manager after printing once, it contains something like: 因此,打印一次后,当我在名称管理器中检查Print_Area时,它包含以下内容:

=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? 有没有一种方法可以防止Print_Area将公式转换为计算值,而是在每次打印时都使用公式? 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) 创建一个名为Test的新名称,并将其值设置为(请注意,我使用的是逗号而不是分号。我设置了美国语言)

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

Set your Print_Area name to 将您的Print_Area名称设置为

=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. 当我使用INDIRECT将Print_Area设置为公式时,打印后不会替换。

See this linked file. 请参阅此链接文件。 https://www.dropbox.com/s/pgm0iv19u6igdm5/Book1.xlsx https://www.dropbox.com/s/pgm0iv19u6igdm5/Book1.xlsx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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