Perfectly functioning macr in 2003 is nor running on 2010 version.

tony666

New Member
Joined
Oct 12, 2010
Messages
10
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 -->
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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,215,387
Messages
6,124,633
Members
449,177
Latest member
Sousanna Aristiadou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top