LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Dynamic Sheet & Range Page Setup & Printing

Hi Team

Have been playing with this for the past hour or so and require your help please.

Now, I use the following to select a worksheet based on a fixed cell value:

If Not ws.Cells(myCell, "A").Value Is Nothing Then Sheets("" & myCell).Activate.

I am trying to incorporate this into my Dynamic Print Sheet selection, alas it does not work.

Essentially, the code looks @ If ws.Cells(i, "H").Value = "Y", if it does then go to that sheet.name and set it up for .PrintPreview/.Printing.

Dim ws As Worksheet
Dim i, ii, Count, lRow As Long
Dim myRng As Range

ii = 51
Set ws = Sheets("Fleet Summary")

For i = 5 To 50
If Not ws.Cells(i, "H").Value = "Y" Then Exit For

With ws
If Not .Cells(i, "A").Value Is Nothing Then
Sheets("" & i).Activate
End If
End With

With ActiveSheet
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
Count = lRow
Set myRng = .Range("A1", "K" & Count)
If lRow < 70 Then
.ResetAllPageBreaks
.PageSetup.PrintArea = myRng.Address
While Count 0 And ii < lRow
If Count 51 Then
.HPageBreaks.Add befo=.Rows(ii)
End If
Wend
End If
.PageSetup.PaperSize = xlPaperA4
.PageSetup.Orientation = xlLandscape
.PageSetup.FitToPagesWide = 1
.PageSetup.FitToPagesTall = False
.PageSetup.LeftMargin = Application.CentimetersToPoints(28.347)
.PageSetup.RightMargin = Application.CentimetersToPoints(28.347)
.PageSetup.TopMargin = Application.CentimetersToPoints(28.347)
.PageSetup.BottomMargin = Application.CentimetersToPoints(28.347)
.PageSetup.HeaderMargin = Application.CentimetersToPoints(0)
.PageSetup.FooterMargin = Application.CentimetersToPoints(0)
.PageSetup.PrintTitleRows = "$1:$7"
.PageSetup.PrintTitleColumns = ""
.PageSetup.LeftHeader = ""
.PageSetup.CenterHeader = ""
.PageSetup.RightHeader = ""
.PageSetup.LeftFooter = ""
.PageSetup.CenterFooter = ""
.PageSetup.RightFooter = ""
.PageSetup.PrintHeadings = False
.PageSetup.CenterHorizontally = True
.PageSetup.CenterVertically = False
.PrintPreview
End With
Next i

TIA
Cheers
Mark.
 
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
Dynamic Range Setup... Trevor Williams[_2_] Excel Worksheet Functions 8 July 29th 09 04:05 PM
Page Setup Printing Sharon Excel Discussion (Misc queries) 0 December 6th 06 02:55 PM
can VBA be used to set page setup for printing? Dave F Excel Discussion (Misc queries) 2 November 21st 06 06:27 PM
Calculate page setup zoom value for 1 to 1 printing mgill Excel Programming 0 March 9th 05 08:17 PM
Excel Printing and Page Setup Sherry Excel Discussion (Misc queries) 1 January 25th 05 09:38 PM


All times are GMT +1. The time now is 02:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"