ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB Script to insert row and calculate a range (https://www.excelbanter.com/excel-programming/375894-vbulletin-script-insert-row-calculate-range.html)

rlee1999

VB Script to insert row and calculate a range
 
Sorry, I am new to this. Please forgive my ignorance.

I recorded a macro that sorts items first by class (ie.108 or 217 located in
column F) and then by dollar amount (located in column S). There may be 10
items in a class.

I need the script to locate the last occurance of the class number (Column
F) on the sheet and then insert a row below.

The script needs to sum the dollar amounts in the new row in Column S.

I would appreciate any help I can get.

~Robert

Bob Phillips

VB Script to insert row and calculate a range
 

Dim LastRow As Long
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
Cells(LastRow + 1, "S").FormulaR1C1 = "=SUM(R1C19:R[-1]C19)"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rlee1999" wrote in message
...
Sorry, I am new to this. Please forgive my ignorance.

I recorded a macro that sorts items first by class (ie.108 or 217 located

in
column F) and then by dollar amount (located in column S). There may be 10
items in a class.

I need the script to locate the last occurance of the class number (Column
F) on the sheet and then insert a row below.

The script needs to sum the dollar amounts in the new row in Column S.

I would appreciate any help I can get.

~Robert




rlee1999

VB Script to insert row and calculate a range
 
Thank you for your quick reply. I inserted this into my macro after the sort
and it did not act as expected. I have 22 different classes, I need a row
insert after each class and to sum the total dollar amount for each class in
the new row.

As is Needs to be
A B...F...............AI A B...F...............AI
125 216.70 125 216.70
125 760.93 125 760.93
125 119.36 125 119.36
124 361.33
1189.06
124 105.80 124
361.33
124
105.80

467.13


In my original post I stated as an example, that the dollar amounts to be
summed were in Column S, which may have been an error on my part. The Dollar
amounts are actually in Column AI.

I hope you can help.

Thank you,

~Robert

"Bob Phillips" wrote:


Dim LastRow As Long
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
Cells(LastRow + 1, "S").FormulaR1C1 = "=SUM(R1C19:R[-1]C19)"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rlee1999" wrote in message
...
Sorry, I am new to this. Please forgive my ignorance.

I recorded a macro that sorts items first by class (ie.108 or 217 located

in
column F) and then by dollar amount (located in column S). There may be 10
items in a class.

I need the script to locate the last occurance of the class number (Column
F) on the sheet and then insert a row below.

The script needs to sum the dollar amounts in the new row in Column S.

I would appreciate any help I can get.

~Robert





Bob Phillips

VB Script to insert row and calculate a range
 
I presume that this has been superseded by your later post?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rlee1999" wrote in message
...
Thank you for your quick reply. I inserted this into my macro after the

sort
and it did not act as expected. I have 22 different classes, I need a row
insert after each class and to sum the total dollar amount for each class

in
the new row.

As is Needs to be
A B...F...............AI A

B...F...............AI
125 216.70 125

216.70
125 760.93 125

760.93
125 119.36 125

119.36
124 361.33
1189.06
124 105.80 124
361.33
124
105.80

467.13


In my original post I stated as an example, that the dollar amounts to be
summed were in Column S, which may have been an error on my part. The

Dollar
amounts are actually in Column AI.

I hope you can help.

Thank you,

~Robert

"Bob Phillips" wrote:


Dim LastRow As Long
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
Cells(LastRow + 1, "S").FormulaR1C1 = "=SUM(R1C19:R[-1]C19)"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"rlee1999" wrote in message
...
Sorry, I am new to this. Please forgive my ignorance.

I recorded a macro that sorts items first by class (ie.108 or 217

located
in
column F) and then by dollar amount (located in column S). There may

be 10
items in a class.

I need the script to locate the last occurance of the class number

(Column
F) on the sheet and then insert a row below.

The script needs to sum the dollar amounts in the new row in Column S.

I would appreciate any help I can get.

~Robert








All times are GMT +1. The time now is 04:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com