+ Reply to Thread
Results 1 to 4 of 4

Apply subtotal when I have a different range

  1. #1
    Registered User
    Join Date
    01-09-2013
    Location
    Medias, Romania
    MS-Off Ver
    Excel 2011
    Posts
    6

    Unhappy Apply subtotal when I have a different range

    Hello,
    I tried to found a solution for my problem, but no succes through other threads.
    I have a row with data, sometimes i have 1000 lines in row, other time I have 100 lines.
    Because i don't want to lose data, I always apply automatic subtotal, I select range(A:B), and sum function. Selecting range A:A somethimes Excel crashes.
    How can i determine the range? Let's say if I have 50 entries then the range is "Range(A1;B50)" this range must be inserted in subtotal function.

    I hope I explained well my problem.
    Thanks in advance.

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Apply subtotal when I have a different range

    HI Ashrak,

    welcome to the forum.
    Suggest you to create a defined name powered with offset / counta functions... post a sample workbook in case you stuck anywhere. Thanks.

    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    01-09-2013
    Location
    Medias, Romania
    MS-Off Ver
    Excel 2011
    Posts
    6

    Re: Apply subtotal when I have a different range

    Thanks, for reply.
    My subtotal function looks like this:

    Columns("A:B").Select
    Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(2), _
    Replace:=True, PageBreaks:=False, SummaryBelowData:=True
    ActiveSheet.Outline.ShowLevels RowLevels:=2
    ActiveSheet.Outline.ShowLevels RowLevels:=2

    I have 2 rows A and B, and applyed subtotal on them.
    In VBA:
    I can't manage how how to replace, Columns("A:B").Select, with my range for example A1:B183.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Apply subtotal when I have a different range

    HI Ashrak

    Please wrap your Code in Code Tags. To do so go to Post #3, Edit Post, Highlight your Code, Click the # symbol, Click Save Changes.

    Try this (not tested)
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1