VBA to put counta subtotal at end of column

nirvehex

Well-known Member
Joined
Jul 27, 2011
Messages
503
Office Version
  1. 365
Platform
  1. Windows
Hi,

How would I put this function into a VBA code that looks at column A and puts this function in the cell after the very last cell with any data in it. Assume there are no blanks within the data in column A.

So I want to find the last row of data in column A and run this formula in the next row down. Furthermore how do I make the ending cell (a14) so it automatically runs the formula to the last cell with data in it.

Code:
=SUBTOTAL(103,'1 yr of PO''s'!$A$2:$A$14)

Thanks.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Try this UNTESTED code:

Code:
Sub SubTtl()

    Dim x As Long
    
    x = Range("A" & Range("A" & Rows.Count).End(xlUp).Row)
    Range("A" & x).Offset(2, 0).Formula = _
        "=SUBTOTAL(103,'1 yr of PO''s'!$A$2:$A$" & x & ")"
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,807
Messages
6,121,679
Members
449,047
Latest member
notmrdurden

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