Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Hide Columns before Print problem

The variable HideCols is used via a form, to establish if the
user wishes to hide any columns before printing.
If so then an InputBox is used to gather those columns to
be hidden, and they are then hidden.

The following code is used to find LastCol and LastCol1:

'This code counts all columns, including hidden
On Error Resume Next
LastCol = Cells.Find("*", After:=.Cells(1), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
'Used with LastCol this code will go on to ignore any columns
'the user has chosen to hide
'MAKE SURE THEY ARE UNHIDDEN IF SAVED AS TRUE
LastCol1 = Range(Cells(1, 1), Cells(1, LastCol)) _
.SpecialCells(xlVisible).Count
On Error GoTo 0

In the following example, the user's ranges to print are
A1:G56, A57:G112, A113:G168 etc. These ranges are
established in an array (Pagevarr) BEFORE the column(s)
if any chosen, are hidden.
LastCol = 7, LastCol1 = 6. The user chose to hide Col D.

If HideCols = False Then
ColsToPrint = LastCol 'the original column count
Else
ColsToPrint = LastCol1 'omit the hidden columns
End If

'Build an array of the ranges to be printed
ReDim Printvarr(1 To 1)
For j = 1 To UBound(Pagevarr) - 1
'nb: change the Resize value to suit the number of columns
'to be printed
Set rng1 = Range(Pagevarr(j), Pagevarr(j + 1).Offset(-1, 0)) _
.Resize(, ColsToPrint)

I think this is correct, so far?

Later code runs, but when I test the range to be printed I find
that it is correct for the rows, and correct in hiding Col D, but it
is not showing Col G (the original last column) in printpreview..

The later code deals with pagesetup stuff, and I can't see any
relevence there.

Can anyone help, please?

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.505 / Virus Database: 302 - Release Date: 30/07/2003


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
Want to Hide columns in spreadsheet but NOT hide data in chart. KrispyData Charts and Charting in Excel 1 March 20th 09 04:45 PM
Print problem with columns Still learning@work New Users to Excel 2 October 21st 08 10:30 AM
How to show columns/cells in sheet but hide them in print? Jeff Korn Excel Discussion (Misc queries) 8 May 25th 08 05:54 PM
Hide/Unhide columns using button on top over relevant columns [email protected] Excel Discussion (Misc queries) 1 March 7th 07 09:24 PM
HIDE WHEN I PRINT qwerty Excel Discussion (Misc queries) 2 November 2nd 05 12:56 AM


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