Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Macro to print a dynamic range

I appreciate any insights you experts can give to me.

I want to use multiple command buttons on a single worksheet to print
associated subsets (ranges) of worksheet data that may vary. In each case I
would like to search the worksheet for "planted" text strings (that will
indicate the upper-left and lower-right limits of a desired print range) and
return those locations into the
ActiveSheet.PageSetup.PrintArea = "loc upper-left:loc lower-right"
function.

Can this be accomplished? Thanks
--
Russ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Macro to print a dynamic range

A couple of ideas come to mind:
1. Create dynamic ranges, say MyRange1,...MyRange2 whatever:
InsertNameDefine Enter MyRange1 in the Name box.
Below in the RefersTo box enter (with the equal sign)

=Offset(Sheet1!$B$2,0,0,CountA(Sheet1!$B$2:$B$1000 ),1)

The 1st argument is the upper left cell of you range.
The 1000 is beyond the max rows you will ever expect you will need.
The last 1 is the number of columns in your range - its width.
As you add/delete data to the lower end of your range or insert rows, the
range definition changes to accomodate the data

Then you can simply print this range with:
ActiveSheet.PageSetup.PrintArea = MyRange1.Address

Does this help?


"Russ" wrote:

I appreciate any insights you experts can give to me.

I want to use multiple command buttons on a single worksheet to print
associated subsets (ranges) of worksheet data that may vary. In each case I
would like to search the worksheet for "planted" text strings (that will
indicate the upper-left and lower-right limits of a desired print range) and
return those locations into the
ActiveSheet.PageSetup.PrintArea = "loc upper-left:loc lower-right"
function.

Can this be accomplished? Thanks
--
Russ

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Macro to print a dynamic range

Hi,

The following may help to get you going.
Assuming that your text string is in B4 - I assume you will know how to find
the cell containing the string.

Sub AAATest()
Dim Parea
Parea = Range("B4")'or Cells(4, 2)
ActiveSheet.PageSetup.PrintArea = Parea
End Sub

regards,
Don

"Russ" wrote in message
...
I appreciate any insights you experts can give to me.

I want to use multiple command buttons on a single worksheet to print
associated subsets (ranges) of worksheet data that may vary. In each case
I
would like to search the worksheet for "planted" text strings (that will
indicate the upper-left and lower-right limits of a desired print range)
and
return those locations into the
ActiveSheet.PageSetup.PrintArea = "loc upper-left:loc
lower-right"
function.

Can this be accomplished? Thanks
--
Russ



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Macro to print a dynamic range

gocush, This helps but I am unclear on whether this technique will return
the location of the two cells of interest.

Does Excel have a function that will return the "alpha:numeric" vector of a
cell that contains a specified value? If so, I could search for that value
and return the vector into the "PrintArea...." function.

"gocush" wrote:

A couple of ideas come to mind:
1. Create dynamic ranges, say MyRange1,...MyRange2 whatever:
InsertNameDefine Enter MyRange1 in the Name box.
Below in the RefersTo box enter (with the equal sign)

=Offset(Sheet1!$B$2,0,0,CountA(Sheet1!$B$2:$B$1000 ),1)

The 1st argument is the upper left cell of you range.
The 1000 is beyond the max rows you will ever expect you will need.
The last 1 is the number of columns in your range - its width.
As you add/delete data to the lower end of your range or insert rows, the
range definition changes to accomodate the data

Then you can simply print this range with:
ActiveSheet.PageSetup.PrintArea = MyRange1.Address

Does this help?


"Russ" wrote:

I appreciate any insights you experts can give to me.

I want to use multiple command buttons on a single worksheet to print
associated subsets (ranges) of worksheet data that may vary. In each case I
would like to search the worksheet for "planted" text strings (that will
indicate the upper-left and lower-right limits of a desired print range) and
return those locations into the
ActiveSheet.PageSetup.PrintArea = "loc upper-left:loc lower-right"
function.

Can this be accomplished? Thanks
--
Russ

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
Print Dynamic Range Bruister via OfficeKB.com Excel Discussion (Misc queries) 1 January 31st 10 02:35 PM
Macro print range not dynamic like I wanted it to be TRYING Excel Worksheet Functions 8 November 27th 07 01:05 AM
Dynamic Print Range Help waxwing Excel Worksheet Functions 2 February 21st 05 03:47 PM
Excel 2000 VBA - Set Print Range in dynamic range sub_pop[_5_] Excel Programming 2 July 27th 04 08:01 PM
Dynamic Print Range John Michl[_2_] Excel Programming 0 April 30th 04 10:47 PM


All times are GMT +1. The time now is 09:33 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"