Hi everyone,
Could anyone please tell me how to write a VBA to do this simple task (but not easy for me ^^!, sadly)?
I have a workbook that contains many sheets (maybe 30 sheets or more) which their names are quite random.
Then I will create a sheet named Master and calculate very simple formular like this:
That is the sum of all the multiplication of two cells of two column (A & B) on the same row (e.g. A2 * B2), for all of the sheets available on the workbook.
All the sheets I want to calculate have the same structure: column A and B with number, start from row 2. Also, the number of rows is the same in every sheets.
This is the samples in XL2BB:
SheetA:
SheetB:
SheetC:
The sheet Master I want to calculate from all other sheets:
The structure is simple but when typing for too many sheets, usually mistakes happened then it will be a huge problem for my final result.
The point here is that:
The code should calculate all available sheets without knowing sheets' names, and paste to the current active sheet (e.g. Master).
Really appreciate your help!
Could anyone please tell me how to write a VBA to do this simple task (but not easy for me ^^!, sadly)?
I have a workbook that contains many sheets (maybe 30 sheets or more) which their names are quite random.
Then I will create a sheet named Master and calculate very simple formular like this:
Excel Formula:
=SheetA!A2*SheetA!B2+SheetB!A2*SheetB!B2+SheetC!A2*SheetC!B2..........
That is the sum of all the multiplication of two cells of two column (A & B) on the same row (e.g. A2 * B2), for all of the sheets available on the workbook.
All the sheets I want to calculate have the same structure: column A and B with number, start from row 2. Also, the number of rows is the same in every sheets.
This is the samples in XL2BB:
SheetA:
Fomular-test-3.xlsm | ||||
---|---|---|---|---|
A | B | |||
1 | Title A | Title B | ||
2 | 0.537552278 | 0.3560159 | ||
3 | 0.728059909 | 0.0117653 | ||
4 | 0.231946094 | 0.8570487 | ||
5 | 0.369968555 | 0.7705613 | ||
6 | 0.451232307 | 0.9802114 | ||
SheetA |
SheetB:
Fomular-test-3.xlsm | ||||
---|---|---|---|---|
A | B | |||
1 | Title A | Title B | ||
2 | 0.801403328 | 0.398481 | ||
3 | 0.654761892 | 0.415879 | ||
4 | 0.887848563 | 0.7809355 | ||
5 | 0.096687559 | 0.1760872 | ||
6 | 0.897179486 | 0.115832 | ||
SheetB |
SheetC:
Fomular-test-3.xlsm | ||||
---|---|---|---|---|
A | B | |||
1 | Title A | Title B | ||
2 | 0.93357177 | 0.5453227 | ||
3 | 0.428093125 | 0.8806354 | ||
4 | 0.219500915 | 0.6875302 | ||
5 | 0.310767214 | 0.3542 | ||
6 | 0.038372637 | 0.9443508 | ||
SheetC |
The sheet Master I want to calculate from all other sheets:
Fomular-test-3.xlsm | |||
---|---|---|---|
A | |||
1 | Across | ||
2 | 1.019819025 | ||
3 | 0.657861573 | ||
4 | 1.043055101 | ||
5 | 0.41218262 | ||
6 | 0.582462382 | ||
Master |
Cell Formulas | ||
---|---|---|
Range | Formula | |
A2:A6 | A2 | =SheetA!A2*SheetA!B2+SheetB!A2*SheetB!B2+SheetC!A2*SheetC!B2 |
The structure is simple but when typing for too many sheets, usually mistakes happened then it will be a huge problem for my final result.
The point here is that:
The code should calculate all available sheets without knowing sheets' names, and paste to the current active sheet (e.g. Master).
Really appreciate your help!