#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default PRINTAREA

I have a little question...
I have an excel file and with a command button I'm trying to
print 2 columnes and the name of the file at the top of the page...
I know how to print a column (for exemple from A10 to A30) with this command

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$10:$A$30"
End Sub

But if I have to print the column E10-E30 too...how can I do?
I've tried with this subroutine

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$7:$A$30,$E$7:$E$30"
Application.Dialogs(xlDialogPrint).Show
End Sub

Now I can print the two columnes but in two different papers!!!
And how can I obtain the file name in my printing?
I' sure that my question is not so clear!!!!
Sorry for my english and for my stupid question!

Thanks

Giacomo


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default PRINTAREA

Try this

It will hide the columns B:D and print
and unhide the columns after that

Sub test()
With ActiveSheet
.Columns("B:D").Hidden = True
.Range("a10:E30").PrintOut
.Columns("B:D").Hidden = False
End With
End Sub

For a filename see File Page Setup(Header and footer)

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Giacomo" wrote in message ...
I have a little question...
I have an excel file and with a command button I'm trying to
print 2 columnes and the name of the file at the top of the page...
I know how to print a column (for exemple from A10 to A30) with this command

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$10:$A$30"
End Sub

But if I have to print the column E10-E30 too...how can I do?
I've tried with this subroutine

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$7:$A$30,$E$7:$E$30"
Application.Dialogs(xlDialogPrint).Show
End Sub

Now I can print the two columnes but in two different papers!!!
And how can I obtain the file name in my printing?
I' sure that my question is not so clear!!!!
Sorry for my english and for my stupid question!

Thanks

Giacomo




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default PRINTAREA

Great!!!!

Thanks a lot man!

"Ron de Bruin" ha scritto nel messaggio
...
Try this

It will hide the columns B:D and print
and unhide the columns after that

Sub test()
With ActiveSheet
.Columns("B:D").Hidden = True
.Range("a10:E30").PrintOut
.Columns("B:D").Hidden = False
End With
End Sub

For a filename see File Page Setup(Header and footer)

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Giacomo" wrote in message

...
I have a little question...
I have an excel file and with a command button I'm trying to
print 2 columnes and the name of the file at the top of the page...
I know how to print a column (for exemple from A10 to A30) with this

command

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$10:$A$30"
End Sub

But if I have to print the column E10-E30 too...how can I do?
I've tried with this subroutine

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$7:$A$30,$E$7:$E$30"
Application.Dialogs(xlDialogPrint).Show
End Sub

Now I can print the two columnes but in two different papers!!!
And how can I obtain the file name in my printing?
I' sure that my question is not so clear!!!!
Sorry for my english and for my stupid question!

Thanks

Giacomo






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default PRINTAREA

If your print area has discontinuous sub-areas, they will print on
different sheets. You can, however, hide the intervening columns:


Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$7:$E$30"
Columns("B:D").Hidden = True
ActiveSheet.Printout
Columns("B:D").Hidden = False
End Sub





In article ,
"Giacomo" wrote:

I have a little question...
I have an excel file and with a command button I'm trying to
print 2 columnes and the name of the file at the top of the page...
I know how to print a column (for exemple from A10 to A30) with this command

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$10:$A$30"
End Sub

But if I have to print the column E10-E30 too...how can I do?
I've tried with this subroutine

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$7:$A$30,$E$7:$E$30"
Application.Dialogs(xlDialogPrint).Show
End Sub

Now I can print the two columnes but in two different papers!!!
And how can I obtain the file name in my printing?
I' sure that my question is not so clear!!!!
Sorry for my english and for my stupid question!

Thanks

Giacomo


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default PRINTAREA

thank you very much!!!!

too kind....

"J.E. McGimpsey" ha scritto nel messaggio
...
If your print area has discontinuous sub-areas, they will print on
different sheets. You can, however, hide the intervening columns:


Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$7:$E$30"
Columns("B:D").Hidden = True
ActiveSheet.Printout
Columns("B:D").Hidden = False
End Sub





In article ,
"Giacomo" wrote:

I have a little question...
I have an excel file and with a command button I'm trying to
print 2 columnes and the name of the file at the top of the page...
I know how to print a column (for exemple from A10 to A30) with this

command

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$10:$A$30"
End Sub

But if I have to print the column E10-E30 too...how can I do?
I've tried with this subroutine

Private Sub CommandButton5_Click()
ActiveSheet.PageSetup.PrintArea = "$A$7:$A$30,$E$7:$E$30"
Application.Dialogs(xlDialogPrint).Show
End Sub

Now I can print the two columnes but in two different papers!!!
And how can I obtain the file name in my printing?
I' sure that my question is not so clear!!!!
Sorry for my english and for my stupid question!

Thanks

Giacomo




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
copy printarea from more than 3 sheet & save in new book. Shital Excel Programming 1 October 4th 03 10:47 AM
Asking user to set a printarea when none is defined Michael J. Malinsky Excel Programming 0 July 23rd 03 06:34 PM


All times are GMT +1. The time now is 11:15 PM.

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"