+ Reply to Thread
Results 1 to 11 of 11

Excel Table: find sum of databodyrange

  1. #1
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Excel Table: find sum of databodyrange

    I have a table with varying columns and rows. I need to calculate the sum of the entire databodyrange. I tried the following without success:

    Please Login or Register  to view this content.
    Suggestions greatly appreciated!

    tom

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Table: find sum of databodyrange

    Please Login or Register  to view this content.
    You probably need to specify the column no as well, unless all columns are to be added. Like

    chkEmpty = WorksheetFunction.Sum(lo.ListColumns(4).DataBodyRange)

  3. #3
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Excel Table: find sum of databodyrange

    Thanks AB33,

    I suppose I could use ListColumns but how would I list all of the columns that way?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Table: find sum of databodyrange

    If it all columns why do not you use bodyrange then?

    CountCol = lo.ListColumns.Count ' gives the columns count.

    No tested
    chkEmpty = WorksheetFunction.Sum(lo.ListColumns.DataBodyRange)

  5. #5
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Excel Table: find sum of databodyrange

    That's the problem. I WANTED to use DataBodyRange but if you will look at the code, it does not work so that is what I need help with fixing.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Table: find sum of databodyrange

    I have now tested it and it works on my sample.

    chkEmpty = WorksheetFunction.Sum(lo.DataBodyRange)

    My sample has column A as string address and the remaining columns are numbers.

  7. #7
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Excel Table: find sum of databodyrange

    Strange. It worked for me on a simple test file too.... gotta check what is different about my production file.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Table: find sum of databodyrange

    In post 2, I highlighted with red the errors on your code. Table names are so weird, so you need to double check the names as well.

  9. #9
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Excel Table: find sum of databodyrange

    here is the line that is not working:

    chkEmpty = WorksheetFunction.Sum(lo1.DataBodyRange.value)

    The error I get on my production file is: Application-define or object-defined error.

    any thoughts?

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Table: find sum of databodyrange

    chkEmpty = WorksheetFunction.Sum(lo.DataBodyRange.value)

    Not

    chkEmpty = WorksheetFunction.Sum(lo1.DataBodyRange.value)

  11. #11
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Excel Table: find sum of databodyrange

    Hey AB33,

    As Pogo once said, "We have found the enemy and he is us."

    The problem was with my original production table. User error.

    Thanks for your effort!

    tom

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Unable to find last row in excel table
    By kevivu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-02-2015, 06:36 AM
  2. DataBodyRange.delete functioncrashes excel2010
    By smjjvh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-07-2015, 12:57 PM
  3. Copy table DataBodyRange to another table Loop
    By jockywilson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-19-2014, 11:38 AM
  4. [SOLVED] How to delete databodyrange in listobject?
    By Jacc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-11-2013, 12:53 PM
  5. [SOLVED] ListObject DataBodyRange Returns Object Variable Not Set Error
    By goss in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2013, 01:51 PM
  6. Excel - Find a value in a Table !!??!!
    By herve in forum Excel General
    Replies: 4
    Last Post: 09-16-2005, 09:05 AM
  7. [SOLVED] Count nullstrings in pivot table (databodyrange)
    By jonasmj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2005, 10:06 AM

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