VBA for Subtotal with conditionals

Copper Contributor

How do I write in VBA code to get the Subtotal of Column I of ONLY the fields that have a Basic Fin date (Column E) that is equal to or less than today? I have a loop through activity for the merged cells in column A and it works fine until I get the range that is not sorted by ascending date, nor do I want to sort it as a work around....

 

Mtwining230_0-1669668199279.png

 

1 Reply

You ask for a VBA code, but have you tried the SUMIF function? If not, here's a link describing it, how to use it.

(By the way, as a general rule, people involved in Excel a lot try to avoid using merged cells; they have a tendency to create havoc with data integrity. Merged cells can make a spreadsheet look nicer to the human eye, but there are downsides when it comes to actually using the data. You can (if it's important to you) achieve much the same result by using conditional formatting to "white-out" the text whenever the value above is the same...or whatever condition is being used as the basis for the merging)