+ Reply to Thread
Results 1 to 4 of 4

Enter a sum formula in each of an unknown number of rows - macros

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Enter a sum formula in each of an unknown number of rows - macros

    Hello,
    I currently have a macro that runs across 31 sheets to copy and paste data from each of them into one place. The number of rows that the macro takes is dependent on the information in the sheets and will most likely be different every time you use it. I am trying to get a summation of each row in the column to the right of the table. This is easily done by typing for instance '=sum(L3:P3) in cell O3 and then dragging the corner down to copy the formula to the bottom of the table, however, there may be hundreds to thousands of rows and, as I said before, it is never the same.
    Any ideas on the macro I could use to accomplish this so I don't have to manually drag that formula every time?

    Thank you in advance

  2. #2
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Enter a sum formula in each of an unknown number of rows - macros

    EDIT: Perhaps adding a For Statement (although I don't know how to use one) that uses the Rows.Count function. But I wouldn't know how to word the 'for-statement' correctly.
    Perhaps something like:

    EndRow = Sheet31.Cells(Rows.Count, "M").End(xlUp).Row
    the counting interger would count the rows (from row 3 to EndRow) and the column would always remain the same (column O)
    in each cell it would enter the following :=sum(L3:P3), =sum(L4:P4), ..... all the way to L'Endrow':P'Endrow'

    Again, I'm not sure how for statements work, but I think this is the right idea.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Enter a sum formula in each of an unknown number of rows - macros

    You shouldn't need a loop.

    Assuning the formula is to go in the column to the right of the columns you are summming, ie column Q:
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Enter a sum formula in each of an unknown number of rows - macros

    Thank you very much, I believe that did the trick.
    You have been very helpful.
    Reputation Added (not like you needed it)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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