summing a range of inserted column

Ali Balleya

New Member
Joined
Feb 18, 2020
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
I have a workbook with Ten worksheets. Each sheet has 14 columns, with the range(d6:l7) named "subists".
With headers (Subst_1, Subst_2, Subst_3, Subst_4, Subst_5, Subst_6, Subst_7, Subst_8, Subst_9)

With range(L8:L107) Named "Subst_9". Row 108 has the columns sums

Some times I need to insert a column before range(subst_9) and fill the new column with the subst amount, and sum it in row 108.
Iused the following Macro to do this. And it works O.K for inserting the column and fill it with substAmnt.
What I need is a way to include the sum of the column at the bottom

Subists is name for range(d6:L7)
SubstName = "New_Sub"
SubstAmnt = 100

'"st" is the start row of the range to fill
'"er" is the end row of the range to fill
'"tr" is the sum row
'"I" refers to the inserted column

Worksheets(Sheet1).Select

With Worksheets(Sheet1).Names("Subists").RefersToRange
Set x = .Find(SubstName, LookIn:=xlValues)
If Not x Is Nothing Then
firstAddress = x.Address
Else
Worksheets(Sheet1).Names("Subist_L").RefersToRange.EntireColumn.Insert
Set x = .Find("", LookIn:=xlValues(
If Not x Is Nothing Then
firstAddress = x.Address
x.Value = SubstName
colCount = 1
i = x.Column
sr = 8
er = 107
tr = 108
Range(Cells(sr, i), Cells(er, i)).Value = SubstAmnt

'Ineed to insert code to put the sum in range((Cells(sr, i))
End If
End With
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,215,636
Messages
6,125,952
Members
449,276
Latest member
surendra75

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