question

BBGMetalmeccanica-3726 avatar image
0 Votes"
BBGMetalmeccanica-3726 asked TvanStiphout answered

Macro no longer working after downgrade from office 2015 to 2010

Good morning
I wanted to show you this macro that I used and it worked fine until I installed office 2010. First on the pc there was office 2016 installed. I also posted the code, the macro copies a sheet from an excel file and pastes it into another file excel and appends the copy to a sheet.
I can't understand why it doesn't work anymore. If anybody please have any ideas and want to help me.
Greetings and thanks

 Sub AccodaFogliKitamura()
    
   Dim wbk1 As Workbook
   Dim wbk2 As Workbook
   Dim Sheet1 As Worksheet
   Dim Sheet2 As Worksheet
   Dim lriga, lriga2 As Long
   Dim rng1, rng2 As Range
      
      
   Application.ScreenUpdating = False
     
      
    Set wbk1 = Workbooks.Open("C:\Users\fabri\Documents\BBG\BBG-PROGRAMMAZIONE-LAVORO.xlsm")
     
       
    Set Sheet1 = wbk1.Sheets("Kitamura")
       
    With Sheet1
     lriga = .Range("A" & .Rows.Count).End(xlUp).Row
    End With
      
    Set wbk2 = Workbooks.Open("C:\Users\fabri\Documents\BBG\CERCA-DATA-LEVIEN-EURO.xlsm")
     
      
    Set Sheet2 = wbk2.Sheets("FogliAccodati")
       
    With Sheet2
     lriga2 = .Range("A" & .Rows.Count).End(xlUp).Row
    End With
       
    
      
    Sheet1.Range("A2 : K" & lriga).Copy _
    Destination:=Sheet2.Range("A" & lriga2)
    
    Application.ScreenUpdating = True
        
 End Sub
office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TvanStiphout avatar image
0 Votes"
TvanStiphout answered

"it doesn't work" is not very descriptive. What is it supposed to do and does not do anymore?
What happens if you set a breakpoint at the top, and step through the code?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

BBGMetalmeccanica-3726 avatar image
0 Votes"
BBGMetalmeccanica-3726 answered

Yes, sorry. I attach a screenshot of the debug, it practically gets to the set of the first sheet and then exits the routine. Maybe it's the two sets of workbooks one after the other that give the error. I can't get out of it.
Thank you very much for your interest
Fabrizio141331-cattura.png



cattura.png (25.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TvanStiphout avatar image
0 Votes"
TvanStiphout answered

I think you need to close the first workbook before you open the next.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.