Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help creating a variable size printarea marco.

Hi, hopefully someone can point me in the right direction.

I'm having trouble making a macro for a variable size print area.

My code so far:
Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$B$8:$H$273"
Range("G5").Select

In the example above when i create the macro i have text in the area from B8
to H273, but if my text changes, the macro still selects this range to
printarea, making the area either to big or to small.

I have tried using this command from another workbook, but the results are
not what I'm looking for:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Need help creating a variable size printarea marco.

You don't need the lines that select ranges.. Try it this way

ActiveSheet.PageSetup.PrintArea = ActiveSheet.UsedRange.Address




"E.Sortland" wrote:

Hi, hopefully someone can point me in the right direction.

I'm having trouble making a macro for a variable size print area.

My code so far:
Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$B$8:$H$273"
Range("G5").Select

In the example above when i create the macro i have text in the area from B8
to H273, but if my text changes, the macro still selects this range to
printarea, making the area either to big or to small.

I have tried using this command from another workbook, but the results are
not what I'm looking for:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need help creating a variable size printarea marco.

This selects all everything in the workbook. I have some text boxes outside
the selected range that gets included, even though they have been set as do
not print in their properties using your suggestion... ?

Some more background. I have "static" information in A1-H7 and A8-A315

This has been entered into print setup "titles" (norwegian excel so I do not
know the exact wording in english)

So i want to select printarea from B8 - Bx to H8 - Hx. x can be anything
from 8 to 322. Setting this manually works without problems.

Also: the area D8-H322 contains forumlas used to look up SKU numbers in
B8-322, so they contain "information" even when displaying "".

Just need to know the "code" for a the current "selection-range".

Best regards,
E.Sortland

"Vergel Adriano" wrote:

You don't need the lines that select ranges.. Try it this way

ActiveSheet.PageSetup.PrintArea = ActiveSheet.UsedRange.Address

"E.Sortland" wrote:

Hi, hopefully someone can point me in the right direction.

I'm having trouble making a macro for a variable size print area.

My code so far:
Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$B$8:$H$273"
Range("G5").Select

In the example above when i create the macro i have text in the area from B8
to H273, but if my text changes, the macro still selects this range to
printarea, making the area either to big or to small.

I have tried using this command from another workbook, but the results are
not what I'm looking for:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Need help creating a variable size printarea marco.

Sorry, I missed that in your question. You do need the lines that select
ranges after all. Anyway, see Tom Ogilvy's response to your question. That
should work. Post back if it still doesn't get you what you're looking for..

"E.Sortland" wrote:

This selects all everything in the workbook. I have some text boxes outside
the selected range that gets included, even though they have been set as do
not print in their properties using your suggestion... ?

Some more background. I have "static" information in A1-H7 and A8-A315

This has been entered into print setup "titles" (norwegian excel so I do not
know the exact wording in english)

So i want to select printarea from B8 - Bx to H8 - Hx. x can be anything
from 8 to 322. Setting this manually works without problems.

Also: the area D8-H322 contains forumlas used to look up SKU numbers in
B8-322, so they contain "information" even when displaying "".

Just need to know the "code" for a the current "selection-range".

Best regards,
E.Sortland

"Vergel Adriano" wrote:

You don't need the lines that select ranges.. Try it this way

ActiveSheet.PageSetup.PrintArea = ActiveSheet.UsedRange.Address

"E.Sortland" wrote:

Hi, hopefully someone can point me in the right direction.

I'm having trouble making a macro for a variable size print area.

My code so far:
Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$B$8:$H$273"
Range("G5").Select

In the example above when i create the macro i have text in the area from B8
to H273, but if my text changes, the macro still selects this range to
printarea, making the area either to big or to small.

I have tried using this command from another workbook, but the results are
not what I'm looking for:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Need help creating a variable size printarea marco.

Assuming the code you posted selects the proper printarea, then

Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
Range("G5").Select

--
Regards,
Tom Ogilvy


"E.Sortland" wrote:

Hi, hopefully someone can point me in the right direction.

I'm having trouble making a macro for a variable size print area.

My code so far:
Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$B$8:$H$273"
Range("G5").Select

In the example above when i create the macro i have text in the area from B8
to H273, but if my text changes, the macro still selects this range to
printarea, making the area either to big or to small.

I have tried using this command from another workbook, but the results are
not what I'm looking for:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need help creating a variable size printarea marco.

Exactly what I was looking for! Thank you very much.

Best regards,
Espen

"Tom Ogilvy" wrote:

Assuming the code you posted selects the proper printarea, then

Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
Range("G5").Select

--
Regards,
Tom Ogilvy


"E.Sortland" wrote:

Hi, hopefully someone can point me in the right direction.

I'm having trouble making a macro for a variable size print area.

My code so far:
Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$B$8:$H$273"
Range("G5").Select

In the example above when i create the macro i have text in the area from B8
to H273, but if my text changes, the macro still selects this range to
printarea, making the area either to big or to small.

I have tried using this command from another workbook, but the results are
not what I'm looking for:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address


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
Max size of variable? erikcw[_4_] Excel Programming 6 December 2nd 05 06:00 PM
any variable size x taol Excel Programming 1 November 7th 05 04:51 AM
ActiveSheet.PageSetup.PrintArea variable ? MAS Excel Programming 2 May 2nd 05 05:45 PM
Macro Creating Variable and using variable in a SQL statement Jimmy Excel Programming 4 October 25th 04 02:36 AM
How to find out the size of a variable-size array ? Adrian[_7_] Excel Programming 1 July 6th 04 09:12 AM


All times are GMT +1. The time now is 01:15 AM.

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

About Us

"It's about Microsoft Excel"