Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default set up toggle button to set print area

At times I need to print a different section of a spreadsheet.
Is it possible to set up a toggle button to set the area for printing?
For example to print cells a1:a6 you would click on the button once but to
print cells a1:a20 you would click on it again.

Thanks in advance of a favourable reply.

Regards
John D
  #2   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default set up toggle button to set print area

Yes it's possible... I'm not entirely sure what the VBA code would be. I
would recommend two buttons or at least sufficient information so that the
user knows which range is being printed.

Easiest way I think for you to develop the option is to record a macro that
has you set the print area to area 1. Then record one to set the print area
to area 2. Create a button that tells the user (either by changing the
caption of the button or the information in some cell or some other option)
which selection is current, and how to switch to the other range. That
button would/could check to see which print area was currently selected, if
it is one, then select two. If it is two then select one. If it is neither
then you should determine what should be done. (i.e., force range one, force
range two, and/or prompt user.)

The reason for a second button would be to have it print just say a
selection, vice printing the Print area. But totally up to you on
implementation.


"John Davies" wrote:

At times I need to print a different section of a spreadsheet.
Is it possible to set up a toggle button to set the area for printing?
For example to print cells a1:a6 you would click on the button once but to
print cells a1:a20 you would click on it again.

Thanks in advance of a favourable reply.

Regards
John D

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default set up toggle button to set print area

Place a togglebutton from the Control Toolbox Toolbar on the worksheet where
you want this behavior. double click on it to get to the click event, then
modify it to look similar to this:

Private Sub ToggleButton1_Click()
sSh = "'" & ActiveSheet.Name & "'!"
If ToggleButton1.Value Then
ToggleButton1.Caption = "A1:A6"
ActiveSheet.PageSetup.PrintArea = _
sSh & "A1:A6"
Else
ToggleButton1.Caption = "A1:A20"
ActiveSheet.PageSetup.PrintArea = _
sSh & "A1:A20"
End If
End Sub


in the dropdowns a the top, select Worksheet and Activate
put in code like this:

Private Sub Worksheet_Activate()
If ToggleButton1.Value Then
ToggleButton1.Caption = "A1:A6"
ActiveSheet.PageSetup.PrintArea = _
sSh & "A1:A6"
Else
ToggleButton1.Caption = "A1:A20"
ActiveSheet.PageSetup.PrintArea = _
sSh & "A1:A20"
End If
End Sub

Depending on what the user can do, you might need to put that code in the
selectionchange event rather than the activate event. As written, the
caption shows the current PrintArea setting. This seems most intutitive to
me. Modify to suite you individual situation.

--
Regards,
Tom Ogilvy

"John Davies" wrote in message
...
At times I need to print a different section of a spreadsheet.
Is it possible to set up a toggle button to set the area for printing?
For example to print cells a1:a6 you would click on the button once but to
print cells a1:a20 you would click on it again.

Thanks in advance of a favourable reply.

Regards
John D



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
set area in excel not giving me option to set print area? J Littlebear Excel Discussion (Misc queries) 4 April 23rd 23 09:04 PM
File, print area, clear area, is not working cblind New Users to Excel 2 September 12th 07 04:51 PM
Macro - Set Print Area for Changing Data Area ksp Excel Programming 5 May 15th 06 10:20 PM
How do you turn off a print area for a page? (no print area) Grunen Excel Discussion (Misc queries) 4 October 8th 05 07:46 PM
Adding .xla button for Toggle Calculation Button Mike Excel Programming 5 August 19th 05 01:55 PM


All times are GMT +1. The time now is 09:57 AM.

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"