0

I've been running around internet to try to find a solution or at least understand why it does this. I won't write the full code here since it's gigantic but basically, I have a macro that runs multiples calculations on population numbers to give % and stuff like that. Macro works perfectly on his own.

Problem arise later on, I'm currently building a "ReportMaker" that would open various excels and dump the info in a word to automatize the making of any report. When this new workbook calls the initial macro which was working perfectly on his own, I get an overflow error on this line (The one with the arrow in front) :

        If Zone_Primaire = True Then
        
            wb_Resultat.Worksheets("Profil FR").Rows(i).NumberFormat = "0%"
            
    ===>    wb_Resultat.Worksheets("Profil FR").Cells(i, Colonne + 2) = (wb_Resultat.Worksheets("Profil FR").Cells(i - wb_cour.Worksheets("Template").Cells(i, 3), Colonne + 2) - wb_Resultat.Worksheets("Profil FR").Cells(i - wb_cour.Worksheets("Template").Cells(i, 2), Colonne + 2)) / wb_Resultat.Worksheets("Profil FR").Cells(i - wb_cour.Worksheets("Template").Cells(i, 2), Colonne + 2)

        Else

            'wb_Resultat.Worksheets(1).Cells(i, Colonne + 2) = wb_Resultat.Worksheets(1).Cells(i, Nb_Benchmark + Colonne + 5) / wb_Resultat.Worksheets(1).Cells(k, Nb_Benchmark + Colonne + 5)
            
            
            wb_Resultat.Worksheets("Profil FR").Cells(i + Ligne_Insert, Colonne + 2) = (wb_Resultat.Worksheets("Profil FR").Cells(i + Ligne_Insert - wb_cour.Worksheets("Template").Cells(i, 3), Colonne + 2) - wb_Resultat.Worksheets("Profil FR").Cells(i + Ligne_Insert - wb_cour.Worksheets("Template").Cells(i, 2), Colonne + 2)) / wb_Resultat.Worksheets("Profil FR").Cells(i + Ligne_Insert - wb_cour.Worksheets("Template").Cells(i, 2), Colonne + 2)
                      
        End If

I've looked around to understand why such thing would happen and I still can't get how I get this error in specific cases and also there's very few variables able to cause that.

wb_resultat and wb_cour has been dim as workbook, i as integer, colonne as integer

colonne never really exceeds 10 and i is 11

Thank you guys

0 Answers0