Using OFFSET formula to create dynamic print area when cells contain formulas?

%3CLINGO-SUB%20id%3D%22lingo-sub-1554327%22%20slang%3D%22en-US%22%3EUsing%20OFFSET%20formula%20to%20create%20dynamic%20print%20area%20when%20cells%20contain%20formulas%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1554327%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20afternoon%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELooking%20for%20help.%26nbsp%3B%20I'm%20trying%20to%20set%20up%20a%20dynamic%20print%20area%20using%20OFFSET%20but%2C%20for%20the%20sheet%20I'm%20trying%20to%20print%2C%20all%20cells%20contain%20formulas%20so%20I've%20used%20IF%20and%20IFERROR%20to%20make%20them%20show%20as%20blank%20when%20necessary.%26nbsp%3B%20What%20I'm%20finding%20is%20that%20trying%20to%20use%20COUNTA%20to%20define%20the%20range%20of%20rows%20doesn't%20work%20because%20Excel%20considers%20a%20cell%20containing%20a%20formula%20not%20blank%2C%20even%20if%20visually%20it%20is.%26nbsp%3B%20I%20kind%20of%20got%20COUNT%20to%20work%20by%20adding%20a%20number%20to%20the%20column%20header%20for%20a%20column%20that%20will%20contain%20number%20values%2C%20but%20for%20some%20reason%20it%20cuts%20off%20the%20last%20line%20that%20I%20would%20have%20expected%20to%20print.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20data%20in%20the%20sheet%20should%20grow%20and%20shrink%20based%20on%20the%20values%20in%20the%20PRODUCT_DESC%20field%20that%20are%20pulling%20in%20from%20a%20pivot%20table%20in%20another%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20formula%20I'm%20using%20for%20the%20dynamic%20print%20area%20is%20%3DOFFSET(%24A%241%2C0%2C0%2CCOUNT(%24F%3A%24F)%2C12)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20am%20I%20doing%20wrong%20and%20is%20there%20a%20better%20way%20to%20format%20the%20formula%3F%26nbsp%3B%20I've%20attached%20the%20sheet%2C%20but%20I%20had%20to%20break%20the%20links%20since%20they%20link%20to%20protected%20data%2C%20so%20consider%20that%20all%20cells%20in%20columns%20A%20through%20L%20would%20have%20a%20background%20formula%20(except%20for%20E%20and%20H%20which%20are%20manual%20entry%20fields).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20any%20help%20you%20can%20provide!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EChris%20A.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1554327%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1554364%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20OFFSET%20formula%20to%20create%20dynamic%20print%20area%20when%20cells%20contain%20formulas%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1554364%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530974%22%20target%3D%22_blank%22%3E%40umasirhc%3C%2FA%3E%26nbsp%3B%2C%20Since%20you%20have%20the%20data%20in%20an%20Excel%20table%2C%20you%20don't%20have%20to%20do%20any%20math%20calculate%20the%20dynamic%20range.%20Delete%20the%20rows%20that%20are%20empty.%20When%20you%20add%20new%20items%2C%20the%20calculations%20will%20automatically%20get%20filled%20in.%20You%20can%20select%20the%20entire%20Table%20and%20set%20the%20print%20area%20and%20it%20will%20automatically%20resize.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1554395%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20OFFSET%20formula%20to%20create%20dynamic%20print%20area%20when%20cells%20contain%20formulas%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1554395%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530974%22%20target%3D%22_blank%22%3E%40umasirhc%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20formula%20counts%20all%20rows%20not%20exactly%20since%20cells%20have%20formulas%2C%20but%20since%20they%20are%20not%20blank.%20Any%20formula%20returns%20some%20value%2C%20empty%20string%20returned%20is%20also%20the%20value%20of%20text%20type.%3C%2FP%3E%0A%3CP%3ETo%20count%20cells%20ignoring%20cells%20with%20empty%20texts%20you%20may%20use%20something%20like%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMPRODUCT(--(F%3AF%26lt%3B%26gt%3B%22%22))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1554793%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20OFFSET%20formula%20to%20create%20dynamic%20print%20area%20when%20cells%20contain%20formulas%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1554793%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F530974%22%20target%3D%22_blank%22%3E%40umasirhc%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAssuming%20the%20column%20B%20has%20a%20formula%20which%20returns%20the%20text%20values%20in%20your%20actual%20file%2C%20then%20you%20may%20use%20the%20following%20formula%20for%20the%20named%20range...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DOFFSET(Charges!%24A%241%2C0%2C0%2CCOUNTIF(Charges!%24B%3A%24B%2C%22%3F*%22)%2C12)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Good afternoon,

 

Looking for help.  I'm trying to set up a dynamic print area using OFFSET but, for the sheet I'm trying to print, all cells contain formulas so I've used IF and IFERROR to make them show as blank when necessary.  What I'm finding is that trying to use COUNTA to define the range of rows doesn't work because Excel considers a cell containing a formula not blank, even if visually it is.  I kind of got COUNT to work by adding a number to the column header for a column that will contain number values, but for some reason it cuts off the last line that I would have expected to print.

 

The data in the sheet should grow and shrink based on the values in the PRODUCT_DESC field that are pulling in from a pivot table in another file.

 

The formula I'm using for the dynamic print area is =OFFSET($A$1,0,0,COUNT($F:$F),12)

 

What am I doing wrong and is there a better way to format the formula?  I've attached the sheet, but I had to break the links since they link to protected data, so consider that all cells in columns A through L would have a background formula (except for E and H which are manual entry fields).

 

Thanks for any help you can provide!

 

Chris A.

3 Replies

@umasirhc , Since you have the data in an Excel table, you don't have to do any math calculate the dynamic range. Delete the rows that are empty. When you add new items, the calculations will automatically get filled in. You can select the entire Table and set the print area and it will automatically resize.

@umasirhc 

You formula counts all rows not exactly since cells have formulas, but since they are not blank. Any formula returns some value, empty string returned is also the value of text type.

To count cells ignoring cells with empty texts you may use something like

=SUMPRODUCT(--(F:F<>""))

 

@umasirhc 

Assuming the column B has a formula which returns the text values in your actual file, then you may use the following formula for the named range...

 

=OFFSET(Charges!$A$1,0,0,COUNTIF(Charges!$B:$B,"?*"),12)