VBA - Sum Non Contiguous Columns range.

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
983
Office Version
  1. 2010
Platform
  1. Windows
Code:
Hi Team, 


I want to sum Non Contiguous Columns range. Is it possible sum Below formula in a Single formula.
Need help in R1C1 styles sum.


Range("A6").FormulaR1C1 = "=sum(R[-4]C[0]:R[-1]C[0])"
Range("C6").FormulaR1C1 = "=sum(R[-4]C[0]:R[-1]C[0])"
Range("E6").FormulaR1C1 = "=sum(R[-4]C[0]:R[-1]C[0])"
Range("G6").FormulaR1C1 = "=sum(R[-4]C[0]:R[-1]C[0])"
Range("I6").FormulaR1C1 = "=sum(R[-4]C[0]:R[-1]C[0])"


Below code works but it sums all Columns.I want to skip one Column.
Range("A6:I6").FormulaR1C1 = "=sum(R[-4]C[0]:R[-1]C[0])"


Thanks in advance for your help.




Regards,
mg
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Range("A6,C6,E6,G6,I6").Formula = "=sum(A2:A5)"
 
Upvote 0
Hi Footo,


Thank you so much for your help, What if I want to sum horizontally.
This formula sums Complete => Range("A6,C6,E6,G6,I6").Formula = "=sum(A2:A5)"

What if I want sum Range("K2:k6).formula = "=sum (a2,c2,e2,g2,I2).value "

Regards,
mg
 
Upvote 0
Range("K2:k6").formula = "=sum (a2,c2,e2,g2,I2)"
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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