Hi all,
I have a excel macro written in excel 2003.
The macro runs successfully on excel 2003 but since our company decided to change to 2010 the macro is not running properly. I am not sure what to change to be honest. Can some one look at the code and see what needs to be changed.
At the moment it runs but does not loop and some times when it loops it prints out the papers in different orders, not the order I specifically put down on the macro.
Any help? Please
Thanks in advance.
For full code see below....
<!-- BEGIN TEMPLATE: bbcode_php -->
I have a excel macro written in excel 2003.
The macro runs successfully on excel 2003 but since our company decided to change to 2010 the macro is not running properly. I am not sure what to change to be honest. Can some one look at the code and see what needs to be changed.
At the moment it runs but does not loop and some times when it loops it prints out the papers in different orders, not the order I specifically put down on the macro.
Any help? Please
Thanks in advance.
For full code see below....
<!-- BEGIN TEMPLATE: bbcode_php -->
PHP:
Sub PrintUsingDatabase()
Dim FormWks As Worksheet
Dim DataWks As Worksheet
Dim myRng As Range
Dim myCell As Range
Dim iCtr As Long
Dim myAddresses As Variant
Dim lOrders As Long
On Error GoTo skip
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set FormWks = Worksheets("FINAL STATEMENTS")
Set DataWks = Worksheets("DEMISE BREAKDOWNS")
myAddresses = Array("B10", "B20", "B11", "B12", "B13", "B14", "E36", "B1", "C44", "B23", "K143", "K144", "K145", "K146", "K147", "K148", "K149", "K156", "K157", "K158", "K159", "K160", "K161", "K162", "K163", "K164", "K165", "K166", "K167", "K168", "K169", "K173", "K174", "K175", "K180", "K181")
With DataWks
'first row of data to last row of data in column I
Set myRng = .Range("I15", .Cells(.Rows.Count, "I").End(xlUp))
End With
For Each myCell In myRng.Cells
With myCell
If IsEmpty(.Offset(0, -1)) Then
'if the row is not marked, do nothing
Else
.Offset(0, -1).ClearContents 'clear mark for the next time
For iCtr = LBound(myAddresses) To UBound(myAddresses)
FormWks.Range(myAddresses(iCtr)).Value _
= myCell.Offset(0, iCtr).Value
Next iCtr
Application.Calculate 'just in case
'after testing, change to Preview to False to Print
'FormWks.PrintOut Preview:=True
Sheets("FINAL STATEMENTS").Select
Range("A1:E132").Select
Range("A1").Activate
With ActiveSheet.PageSetup
.Orientation = xlPortrait
.Zoom = 90
End With
Selection.PrintOut Copies:=1, Collate:=True
Range("A133:K190").Select
Range("A133").Activate
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.Draft = False
.Zoom = 65
End With
Selection.PrintOut Copies:=1, Collate:=True
Sheets("LH STATEMENTS - THIS YEAR").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("BUDGET vs ACTUAL").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("APPENDIX - A").Select
With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = False
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
If Worksheets("WORKINGS").Range("C63").Value = 0 Then
ActiveWindow.SelectedSheets.PrintOut Copies:=0, Collate:=False
Else
' this is ommiting the Appendix B when there is no Snking Fund Value
Sheets("APPENDIX - B").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
lOrders = lOrders + 1
End If
End With
Next myCell
Sheets("DEMISE BREAKDOWNS").Select
Range("A1").Select
MsgBox lOrders & " order(s) printed."
skip:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub