Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Setting Print Area in VB

I have a problem with being able to set the print area using VB.

The Project I am working on has a sheet (Sheet 1) where details are
entered, and a second sheet (Sheet 2) picks out certain details using
VLOOKUP from Sheet 1. Sheet 1 (and therefore Sheet 2), can have from a
minimum of 3 rows anywhere up to 400 rows. I need to be able to print
an amount of rows inbetween 3 and 400 from Sheet 2.

On Sheet 2 , there are columns which have details in them, but also
have VLOOKUP formlas in them, so using VB to find the bottom of the
column doesn't help here, as it always finds the 400th row, unless
there is a way to search for a blank value!?!?!? I do however have a
column which is copyed from Sheet 1 and pasted in column P on Sheet 2,
these are already values (text).

Using Offsets from column P, I can select the area for which I want to
be printed (this area goes from the bottom of the table to Cell B13),
but I cannot set this as the print area! I have tried coding like...
ActiveSheet.PageSetup.PrintArea = CurrentRegion
and
ActiveSheet.PageSetup.PrintArea = CurrentSelection
either followed by
ActiveSheet.PrintOut Copies:=1
but this still prints all 400 rows!?

Also the page setup is already set to landscape, it is on A4, and the
width of the columns fits on one page.

Any help would be very helpful, i'm doing my nut in and I can't figure
it!!!!


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Excel VBA - Setting Print Area in VB

Per Help, PrintArea is looking for the ADDRESS of a range (a string), not
the range (an object). Try

ActiveSheet.PageSetup.PrintArea = CurrentRegion.Address
OR
ActiveSheet.PageSetup.PrintArea = CurrentSelection.Address

and see if those work.

FYI, the example in Help provides this as an example:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
I don't know if using ActiveCell is 100% required, but in case you have
further problems....

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"spikel " wrote in message
...
I have a problem with being able to set the print area using VB.

The Project I am working on has a sheet (Sheet 1) where details are
entered, and a second sheet (Sheet 2) picks out certain details using
VLOOKUP from Sheet 1. Sheet 1 (and therefore Sheet 2), can have from a
minimum of 3 rows anywhere up to 400 rows. I need to be able to print
an amount of rows inbetween 3 and 400 from Sheet 2.

On Sheet 2 , there are columns which have details in them, but also
have VLOOKUP formlas in them, so using VB to find the bottom of the
column doesn't help here, as it always finds the 400th row, unless
there is a way to search for a blank value!?!?!? I do however have a
column which is copyed from Sheet 1 and pasted in column P on Sheet 2,
these are already values (text).

Using Offsets from column P, I can select the area for which I want to
be printed (this area goes from the bottom of the table to Cell B13),
but I cannot set this as the print area! I have tried coding like...
ActiveSheet.PageSetup.PrintArea = CurrentRegion
and
ActiveSheet.PageSetup.PrintArea = CurrentSelection
either followed by
ActiveSheet.PrintOut Copies:=1
but this still prints all 400 rows!?

Also the page setup is already set to landscape, it is on A4, and the
width of the columns fits on one page.

Any help would be very helpful, i'm doing my nut in and I can't figure
it!!!!


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Setting Print Area in VB

Thanks for the help George! will try this out!

--
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
Print Area Setting RozBuds Excel Discussion (Misc queries) 3 February 19th 10 09:41 PM
Setting The Print-Area ? Robert11[_3_] New Users to Excel 2 May 31st 09 03:24 PM
Setting print area richzip Excel Discussion (Misc queries) 1 April 27th 08 08:10 AM
Setting print area Don Guillett[_4_] Excel Programming 0 September 4th 03 02:14 PM
setting complex print area Myrna Larson[_2_] Excel Programming 3 August 18th 03 04:37 PM


All times are GMT +1. The time now is 09:44 PM.

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"