VBA code to add multiple row and columns excluding other elements

anne2021

New Member
Joined
Dec 4, 2021
Messages
9
Office Version
  1. 2021
Platform
  1. MacOS
I've been working on this VBA code for 2 weeks already and I can't figure out the right code to generate the sums of rows and columns vector. This is an input-output table of 12x12 matrix.

For columns (which are import data), I need to generate the sums of columns: example for range "D21", the sum of "E8:E19" minus "E8"; for range "D22", the sum of "E8-E19" minus "E9".. I need to do the same calculations for the rest of cells in green color.

For rows (which are export data), I need to generate the sums of rows: example for range Q8, the sum of (E8:P8)-E8; Q9, the sum of (E9:P9)-E9.. and so on. I need to sum all the data in each cells excluding the diagonal elements/cells in blue.

My professor asked me to construct the VBA code using subroutine test and loops but I really can't figure it out.

Hope someone can help me construct the VBA code for this.

Please see the excel file in this link (as I cannot attach a copy of the image), data in sheet 3.
https://asiandevbank-my.sharepoint....BNn3y2D24_2IcBGhNuhNAE1v6tg1UJZJAr8w?e=DBBQbj

Would be very grateful for you help.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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