Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help recording a macro to define print area

(Posted also under Excel "crash" section)

I recorded a macro (relative cell reference)
by finding a certain cell by a "find" criterion,
and then shading it with a shift-end-left arrow
and a shift-end-up arrow. I then set this as the print
area and printed it. So far so good. Before finishing the
macro I deleted the Print area from the name box
so that the spreadsheet would be exactly the same
after I cleared the contents, and ready to use again.

When I used a different file with a different number
of records and tried the use the macro, the print
job included only the number of rows in the original
macro. ( Remember I did use a relative reference when
recording). When I looked at the Visual Basic
I saw that the macro recorder recorded the static
cell addresses for the print area (A1:F12, for example).

I thought next, that if I range-named the block before
setting it as the print area that that might work.
No luck.

Is there a trick to shading an area while recording a
relative cell reference macro so that the print area
confoms to the newly defined (shaded) area each time?

Suggestions Welcome, Solutions Moreso.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help recording a macro to define print area

I'm assuming you recorded a find to get something like:

Cells.Find(What:="a", After:=ActiveCell, LookIn:=xlFormulas
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
MatchCase:=False _
, SearchFormat:=False).Activate

If so, first change the .Activate to .Select

Assuming you wanted to select the found row plus the next 11 rows an
the found column plus the next 5 columns, use the following line o
code to make the selection which would be used to set your print area.

Range(Selection, Cells(Selection.Row + 11, Selection.Column
5)).Select

Modify to meet your needs.



--
Message posted from http://www.ExcelForum.com

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
setting the print area from a macro Joe Farruggio Excel Worksheet Functions 10 November 25th 06 01:10 AM
Newbie seeks suggestion on recording new macro to print sheets Vivian New Users to Excel 2 May 10th 06 06:53 AM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Create a print macro that would automatically select print area? wastedwings Excel Worksheet Functions 7 August 22nd 05 10:36 PM
Highlighting a Block of Cells to Define the Print Area Mark[_22_] Excel Programming 8 November 18th 03 03:43 AM


All times are GMT +1. The time now is 10:26 PM.

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"