Ali Balleya
New Member
- Joined
- Feb 18, 2020
- Messages
- 1
- Office Version
- 2010
- Platform
- 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
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