Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Set Print Area

Hi All-

I am successfully using the below macro to define print area. The
number of rows remains constant but the columns vary depending on the
number of tests a person performs. The macro therefore will select and
print the colums that are headed in row A. The row A headers are
linked to other cells in the workbook that define a date.

Range("A1:Z51").Select
ActiveSheet.PageSetup.PrintArea = "A1:OFFSET(A1,50,COUNTA
(A1:Z1)-1)"

this however relies on the cells in row A that are not wanted to be
printed to be blank. I now want to fully automate the wookbook and the
problem I have is now the cells in row A are linked to another cell
(T4 in this instance) that calculates a date, so there is always text
in the row A column headers. I have tried to use the following =IF
(T2,T4,"") (where T2 is date of birth and T4 is calculated age) to
make the cells in Row A appear blank if there is not date of birth
present. However teh COUNTA function obviously works on cells being
totally blank (i.e. not containing formulas) so no longer serves the
purpose.


Has anyone got any ideas on how to alter the PrintArea macro to set
based on whether a cell is displayign a value?

Thanks (as always) for any help offered

Best Wishes

Paul

p.s. apologies if this question appears twice. I thought I posted it
before but can't find it anywhere!!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Set Print Area


1. There is no such thing as row A. Do you mean col A or Row 1?
2. You do not have to use a macro to define the range name. In fact, it only
slows things down.
Use a defined name by insertnamedefine and modify your Print_Area name to

=OFFSET($A$1,0,0,MATCH(9999999,$A:$A),COUNTA($1:$1 ))

which assumes row 1 has data in all cells and column A has numbers and may
have blanks.
Now the print_area will be self adjusting without a macro.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Porky79" wrote in message
...
Hi All-

I am successfully using the below macro to define print area. The
number of rows remains constant but the columns vary depending on the
number of tests a person performs. The macro therefore will select and
print the colums that are headed in row A. The row A headers are
linked to other cells in the workbook that define a date.

Range("A1:Z51").Select
ActiveSheet.PageSetup.PrintArea = "A1:OFFSET(A1,50,COUNTA
(A1:Z1)-1)"

this however relies on the cells in row A that are not wanted to be
printed to be blank. I now want to fully automate the wookbook and the
problem I have is now the cells in row A are linked to another cell
(T4 in this instance) that calculates a date, so there is always text
in the row A column headers. I have tried to use the following =IF
(T2,T4,"") (where T2 is date of birth and T4 is calculated age) to
make the cells in Row A appear blank if there is not date of birth
present. However teh COUNTA function obviously works on cells being
totally blank (i.e. not containing formulas) so no longer serves the
purpose.


Has anyone got any ideas on how to alter the PrintArea macro to set
based on whether a cell is displayign a value?

Thanks (as always) for any help offered

Best Wishes

Paul

p.s. apologies if this question appears twice. I thought I posted it
before but can't find it anywhere!!!!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
set area in excel not giving me option to set print area? J Littlebear Excel Discussion (Misc queries) 4 April 23rd 23 09:04 PM
File, print area, clear area, is not working cblind New Users to Excel 2 September 12th 07 04:51 PM
print area across the freeze panes area tom Excel Worksheet Functions 2 January 6th 07 05:23 PM
Macro - Set Print Area for Changing Data Area ksp Excel Programming 5 May 15th 06 10:20 PM
How do you turn off a print area for a page? (no print area) Grunen Excel Discussion (Misc queries) 4 October 8th 05 07:46 PM


All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"