Thebatfink
Active Member
- Joined
- Apr 8, 2007
- Messages
- 401
Hi,
I'm pulling my hair out here. I have produced this code (snippet below) and it appears to cycle through perfectly and do what I want, but it never prints what I am expecting. For instance -
so it should do
It correctly inserts the .Value Now into both the cells BUT it prints out two copies of "$a$1:$q$43"?!?! Obviously I'm doing something wrong but I can't see what it is
Any help would be greatly appreciated and save whats left of my greying hair!!
Thanks
Batfink
I'm pulling my hair out here. I have produced this code (snippet below) and it appears to cycle through perfectly and do what I want, but it never prints what I am expecting. For instance -
Code:
Private Sub printselected_Click()
With Sheets("Charts").PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.354330708661417)
.RightMargin = Application.InchesToPoints(0.354330708661417)
.TopMargin = Application.InchesToPoints(0.393700787401575)
.BottomMargin = Application.InchesToPoints(0.393700787401575)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
bResponse = Application.Dialogs(xlDialogPrinterSetup).Show
If bResponse = False Then
MsgBox "Printing cancelled by User"
Exit Sub
End If
If aa1toggle.Caption = "Print aa1 Charts" Then
Call printaa1charts
End If
If aa2toggle.Caption = "Print aa2 Charts" Then
Call printaa2charts
End If
If aa3toggle.Caption = "Print aa3 Charts" Then
Call printaa3charts
End If
If aa4toggle.Caption = "Print aa4 Charts" Then
Call printaa4charts
End If
If ab1toggle.Caption = "Print ab1 Charts" Then
Call printab1charts
End If
If ab2toggle.Caption = "Print ab2 Charts" Then
Call printab2charts
End If
If ab3toggle.Caption = "Print ab3 Charts" Then
Call printab3charts
End If
End Sub
Private Sub printaa1charts()
If aa18 = True Then
Sheets("Charts").Range("j1").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$1:$q$43"
Sheets("Charts").PrintOut
If aa116 = True Then
Sheets("Charts").Range("j45").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$45:$q$87"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j1").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$1:$q$43"
Sheets("Charts").PrintOut
End If
If aa124 = True Then
Sheets("Charts").Range("j90").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$90:$q$132"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j45").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$45:$q$87"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j1").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$1:$q$43"
Sheets("Charts").PrintOut
End If
If aa132 = True Then
Sheets("Charts").Range("j134").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$134:$q$176"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j90").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$90:$q$132"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j45").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$45:$q$87"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j1").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$1:$q$43"
Sheets("Charts").PrintOut
End If
If aa140 = True Then
Sheets("Charts").Range("j178").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$178:$q$220"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j134").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$134:$q$176"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j90").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$90:$q$132"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j45").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$45:$q$87"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j1").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$1:$q$43"
Sheets("Charts").PrintOut
End If
End Sub
Code:
aa1toggle.Caption = "Print aa1 Charts" (is true)
aa116 = true (is true)
so it should do
Code:
Sheets("Charts").Range("j45").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$45:$q$87"
Sheets("Charts").PrintOut
Sheets("Charts").Range("j1").Value = Now
Sheets("Charts").PageSetup.PrintArea = "$a$1:$q$43"
Sheets("Charts").PrintOut
It correctly inserts the .Value Now into both the cells BUT it prints out two copies of "$a$1:$q$43"?!?! Obviously I'm doing something wrong but I can't see what it is
Any help would be greatly appreciated and save whats left of my greying hair!!
Thanks
Batfink