Hi! It is me again. And I am back due to my failure of automating the calculations that I wanted.
I have attached the file.
As I wrote I need to divide each cell from column K to V to the sum of each column (calculate the percentage) in the sheet “Main” and write down the result in columns from B to M in the next sheet “Result” of the workbook:
In "Result" sheet in "Gramake_NO_NW" workbook:
B C D
='MAIN!'K2/'MAIN!'K770 ='MAIN!'L2/'MAIN!'L770 ='MAIN!'M2/'MAIN!'M770 So on
='MAIN!'K3/'MAIN!'K770 ='MAIN!'L3/'MAIN!'L770 ='MAIN!'M3/'MAIN!'M770
='MAIN!'K3/'MAIN!'K770 ='MAIN!'L3/'MAIN!'L770 ='MAIN!'M3/'MAIN!'M770
='MAIN!'K4/'MAIN!'K770 ='MAIN!'L4/'MAIN!'L770 ='MAIN!'M4/'MAIN!'M770
='MAIN!'K5/'MAIN!'K770 ='MAIN!'L5/'MAIN!'L770 ='MAIN!'M5/'MAIN!'M770
So on So on So on
The solution of AlphaFrog is working for only one workbook, and I found at that for some reasons it calculates percentages wrongly, i.e. twice less of the value.
I have dozen of these files that need to be calculated this way and each file has the same amount of columns (i.e. from K to V), but the length of these columns differ, i.e. the number of rows is different. So I need something with loops and dynamic variables. I tried to make the range of columns and rows to be array, and as a range, but I can’t. Please help!
So here the script with columns and rows as an array that looks like with the error message of “Subscript out of range” - 1st script.
Or when the columns and rows as a range, then I receive “Type mismatch” and “Overflow” - 2nd script
1)
or
2)
Bookmarks