ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Printing non-adjacent columns (https://www.excelbanter.com/excel-discussion-misc-queries/13418-printing-non-adjacent-columns.html)

Ann Shaw

Printing non-adjacent columns
 
Hi

I know I can hide columns I don't want to print and I know
I can use Group and Outline but that means I have to do
this each time to the columns I want to print and they
could be different each time in the spreadsheet - is there
a quicker way using a macro or something?

Basically I have 45 columns and sometimes I want to print
for example A:E,G,M-P,T and sometimes I want to print
other combinations of columns.

Thanks

Ann

Dave Peterson

Record a macro when you hide your columns, print the worksheet, and unhide the
columns.

Then you could use that as the basis of your code to print the columns you need
to print.

This is what I ended up with (printpreview, though):

Option Explicit
Sub testme()
Dim myRng As Range
With ActiveSheet
Set myRng = .Range("A:E,G:G,M:P,T:T")
.UsedRange.Columns.Hidden = True
myRng.EntireColumn.Hidden = False
.PrintOut preview:=True
.UsedRange.Columns.Hidden = False
End With
End Sub

You could even add some buttons to the worksheet that were assigned to the
different "prints".



Ann Shaw wrote:

Hi

I know I can hide columns I don't want to print and I know
I can use Group and Outline but that means I have to do
this each time to the columns I want to print and they
could be different each time in the spreadsheet - is there
a quicker way using a macro or something?

Basically I have 45 columns and sometimes I want to print
for example A:E,G,M-P,T and sometimes I want to print
other combinations of columns.

Thanks

Ann


--

Dave Peterson


All times are GMT +1. The time now is 01:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com