Adding a range based on criteria

Jtbuman

New Member
Joined
Jun 29, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
I'm having some trouble coming up with a code that will work for this. Any help would be greatly appreciated!!

I need something like..

If the cell in column D shows "Setup" add the cells in column L, going up, but stop adding when the cell in column D shows "Setup" again. Then put that total in column M one row above the row with "Setup".



1624984192576.png
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi & welcome to MrExcel.
How about
VBA Code:
Sub jtbuman()
   Dim Ar As Areas
   Dim Rng As Range
   
   With Range("D2", Range("D" & Rows.Count).End(xlUp))
      .Replace "Setup", "=xxxSetup", xlWhole, , False, , False, False
      Set Ar = .SpecialCells(xlConstants).Offset(, 8).Areas
      .Replace "=xxxSetup", "Setup", xlWhole, , False, , False, False
   End With
   For Each Rng In Ar
      Rng.Offset(-1, 1).Resize(1).Formula = "=sum(" & Rng.Address & ")"
   Next Rng
End Sub
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,140
Members
449,098
Latest member
Doanvanhieu

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