ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SubTotal when Cell Changes (https://www.excelbanter.com/excel-programming/432150-subtotal-when-cell-changes.html)

KalliKay

SubTotal when Cell Changes
 
In my query I would like to have column J (Rentable Square Feet) insert a
subtotal when Owner Entity in Column C changes.

Column C Column J

Owner Entity Rentable Sq Ft
Company A 62,153
Company A 29,951
Company B 125,515
Company B 20,000

Company C 15,81
Company D 103,500
Company D 174,906

I would appreciate any assistance you can give me. Thx.


Jacob Skaria

SubTotal when Cell Changes
 
The below macro will insert a row and assign the subtotal in Col J. Col C
should not have any blanks...

Sub Macro1()
Dim lngRow As Long, lngTemp As Long

lngRow = 3
lngTemp = lngRow - 1

Do While Range("C" & lngRow) < ""
If Range("C" & lngRow) < Range("C" & lngRow - 1) Then
Rows(lngRow).Insert
Range("J" & lngRow) = "=sum(J" & lngTemp & ":J" & lngRow - 1 & ")"
lngRow = lngRow + 1: lngTemp = lngRow
End If
lngRow = lngRow + 1
Loop
Range("J" & lngRow) = "=sum(J" & lngTemp & ":J" & lngRow - 1 & ")"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"KalliKay" wrote:

In my query I would like to have column J (Rentable Square Feet) insert a
subtotal when Owner Entity in Column C changes.

Column C Column J

Owner Entity Rentable Sq Ft
Company A 62,153
Company A 29,951
Company B 125,515
Company B 20,000

Company C 15,81
Company D 103,500
Company D 174,906

I would appreciate any assistance you can give me. Thx.



All times are GMT +1. The time now is 09:54 PM.

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