View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default How to end/up end/across to select print area?

It looks to me as if near the end where you are saying "attempting to make
the selection 3-dimensional...) you are wiping out all the selections you've
already made and made and are selecting A1:BJ121
If you are at BJ121 at that point, a -120 row and -61 column offset takes
you back to cell A1.

One way to see what is going on is to step through that code and watch what
is happening on your spreadsheet. Right above the first line in that section
insert a blank line and type the word Stop
Then run your macro - it will go into debug mode with the word Stop
highlighted. You can then use [F8] to single-step line by line through the
code, keeping an eye on what is actually happening on the sheet. You may
have to resize the VB Editor window to see your worksheet. Don't click on
the worksheet while you're stepping through it - that may change where the
current active cell/reference is at -

You can save some paper by commenting out the Selection.PrintOut statement
during the test (do that at the same time you insert the Stop command)
"Kevryl" wrote:

This should be easy, but it won't work.

I have a cash analysis spreadsheet that expands downwards as it goes, and I
simply want to print the latest month off in a macro that closes the month
and does all sorts of other complex stuff perfectly. I have created a "rail"
on the right hand edge with a "|" character to end/up to a break in that
column. With macro set to "relative" I record shift/end/up from an named
anchor point to select the vertical area, then try to record shift/left left
left etc to select all the columns (as not all cells contain data). I print
and naturally it prints perfectly, but when I run the macro it goes haywire,
printing way up beyond the area selected.

This is how that section of the recorded macro looks:

Application.Goto Reference:="Total" (bottome edge of sheet, left hand
side)
Selection.End(xlUp).Select (goes to last entry)
ActiveCell.Offset(0, 61).Range("A1").Select (goes to final column
containing the 'rail')
Selection.ClearContents (creates a break in the rail for next month)
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select (selects column up to
break in rail at last month)
ActiveCell.Offset(-120, -61).Range("A1:BJ121").Select (attempting to
make the selection 3 dimensional to include all columns)
ActiveCell.Activate
Selection.PrintOut Copies:=1, Collate:=True (Bombs out, printing to
about a month an a half further back than my topmost selection!)


Can anyone tell me where I'm goimg wrong, or offer a solution?

Thanks,
Keith