Autosum specific rows and columns

tezza

Active Member
Joined
Sep 10, 2006
Messages
384
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
  2. Web
Hi all,

Have a look at this:

RC Call Logs 17-06-24 to 19-07-24.xlsx
FGHIJK
1Call Start TimeCall End TimeCall DurationReal StartReal EndDuration
210:0016:0006:0009:4517:5608:11
310:0016:0006:0009:4715:4005:53
410:0016:0006:0009:5115:5306:02
510:0016:0006:0009:5115:4705:56
610:0016:0006:0009:4615:5806:12
710:0016:0006:0009:5815:4905:51
810:0016:0006:0009:4615:5006:04
910:0016:0006:0009:5815:5505:57
1048:0050:06
11
12
1309:4512:4503:0009:3812:4303:05
1409:4512:4503:0009:3912:4603:07
1506:0006:12
16
17
1811:3013:3002:0011:2513:2902:04
1911:3013:3002:0011:2513:3202:07
2011:3013:3002:0011:2513:2502:00
2111:3013:3002:0011:2513:1601:51
2208:0008:02
23
24
2509:3012:3003:0009:2712:1502:48
2610:3013:3003:0010:2913:2802:59
2710:4512:4502:0010:4012:4002:00
2809:3012:3003:0009:2612:1902:53
2910:3013:0002:3010:2613:0502:39
3009:3012:3003:0009:1612:1803:02
3110:4512:4502:0010:4012:4102:01
3209:3012:3003:0009:2412:1102:47
3310:3013:3003:0010:2413:2102:57
3410:4512:4502:0010:4012:3901:59
3526:3026:05
36
37
Call_Logs
Cell Formulas
RangeFormula
H10,K10H10=SUM(H2:H9)
H15,K15H15=SUM(H13:H14)
H22,K22H22=SUM(H18:H21)
H35,K35H35=SUM(H25:H34)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I1:I9999Expression=$M1="Check"textNO
J2:J9999Expression=I2>J2textNO
K1:K9999,B1:B9999Expression=AND(COUNTA(XEV1:D1)>1,$H1-$K1>TIME(0,15,0))textNO
H2:H9999Expression=(Q2*1440)>30textNO
A1:F9999Expression=$R1=$R2textNO


I'm looking for a bit of VBA coding that autosums each break in Col H and then copies that formula to Col K, same row as Col K doesn't always have a full list of times.

When you look at the Cell Formulas box above, that's what I'm looking to automate.

Can you help?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try this:

VBA Code:
Sub autosum()
  Dim ar As Range, i As Long
  
  For Each ar In Range("F2", Range("F" & Rows.Count).End(3)).SpecialCells(xlCellTypeConstants).Areas
    i = ar.Cells(ar.Rows.Count).Row + 1
    With Range("H" & i & ",K" & i)
      .Formula = "=SUM(" & ar.Offset(0, 2).Address(0, 0) & ")"
    End With
  Next
End Sub
 
Upvote 0
Solution
Try this:

VBA Code:
Sub autosum()
  Dim ar As Range, i As Long
 
  For Each ar In Range("F2", Range("F" & Rows.Count).End(3)).SpecialCells(xlCellTypeConstants).Areas
    i = ar.Cells(ar.Rows.Count).Row + 1
    With Range("H" & i & ",K" & i)
      .Formula = "=SUM(" & ar.Offset(0, 2).Address(0, 0) & ")"
    End With
  Next
End Sub
Perfect, thank you.
 
Upvote 0

Forum statistics

Threads
1,224,872
Messages
6,181,498
Members
453,047
Latest member
charlie_odd

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