View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Stuart[_5_] Stuart[_5_] is offline
external usenet poster
 
Posts: 413
Default Continuing print code problem

Yes.
Many thanks.

Regards.

"William" wrote in message
...
Stuart

Does this help?

Sub PrintLayout()
Dim r As Range, c As Range, i As Integer
i = 0
With Sheets("Sheet1")
Set r = .Range("A1:Z1")
For Each c In r
If c.EntireColumn.Hidden = True Then i = i + 1
Next c
If i 8 Then
.PageSetup.Orientation = xlPortrait
Else
.PageSetup.Orientation = xlLandscape
End If
End With
End Sub

--
XL2002
Regards

William


"Stuart" wrote in message
...
| User opens a 15 column workbook, which is to say that
| there is data in all first 15 columns, but not in every cell.
| There is data in row1 for all 15 columns.
|
| They then hide columns E - I inclusive, and I use
| Application.InputBox to catch these columns.
|
| At this point I have LastCol as 15 and I am using this to set
| the print range.
|
| How can I trap the number of columns being hidden, since
| this may help decide whethher to print in portrait or
| landscape, please?
|
| On Error Resume Next
| Set ExclColRng = Application.InputBox("Use the left mouse " & _
| "button with the Control key," & vbNewLine & "to select at least" _
| & " one cell in each column " & vbNewLine & "(or the entire" _
| & ".column), to indicate those" & vbNewLine & "Columns to be" _
| & " hidden. Click OK. when done", Type:=8)
| On Error GoTo 0
|
| and
|
| With ActiveSheet
| ExclColRng.EntireColumn.Hidden = True
| 'Make sure user hasn't hidden col A or £col
| Columns(1).Visible = True
| Columns(£Col).Visible = True
| End With
|
| Any help much appreciated.
|
| 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
|
|




---
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