+ Reply to Thread
Results 1 to 4 of 4

Trouble writing a macro to insert a sum formula with variables into a cell

  1. #1
    Registered User
    Join Date
    04-16-2013
    Location
    Buffalo, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Trouble writing a macro to insert a sum formula with variables into a cell

    I'm new to macros and trying to write a formula within a macro for the first time. I have a large range of data. The number of rows of data will change each time I use the file. The columns could change as well. At the bottom of the data there is a total line but the formula breaks in a sort that I do earlier in the process. I use cells.find to get the row and column numbers for the total line. I am trying to use the variables that come from the cells.find to create my formula but it isn't working right. The result I get in my file is a formula of =sum(359:352086) and the result is #DIV/0!.

    I'd like to sum all of the data in the column from row 9 to the line above the total row.

    HELP PLEASE!


    Please Login or Register  to view this content.
    THANK YOU SO MUCH FOR YOUR TIME!

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Trouble writing a macro to insert a sum formula with variables into a cell

    I think that sum() needs reference of a range (col&row) and not only numbers..

  3. #3
    Registered User
    Join Date
    04-16-2013
    Location
    Buffalo, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Trouble writing a macro to insert a sum formula with variables into a cell

    Thanks for responding to me question. I'm not sure I understand though. I define the variables as row and column numbers first and then try to pull them into the formula. Is that possible?

    THANKS!!

  4. #4
    Registered User
    Join Date
    04-16-2013
    Location
    Buffalo, NY
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Trouble writing a macro to insert a sum formula with variables into a cell

    I think I figured out what you mean. My variable find column 35 and row 2086 so it is putting this formula into the cell:

    =SUM(359:352086) and giving me the error as the result.

    I think I need to figure out how to do this with R1C1. UGH!

+ 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