+ Reply to Thread
Results 1 to 5 of 5

Using Sum with range cell-variable referencing

  1. #1
    Registered User
    Join Date
    07-17-2014
    Location
    Arlington, VA
    MS-Off Ver
    2010
    Posts
    10

    Using Sum with range cell-variable referencing

    Howdy ya'll,

    So, I have created a macro that upon importing a script (I work at a polling firm) as text file formats the file in a particular way. I thought I had finished this project, but my colleague informed that it isn't helpful when a call goes on for multiple days.

    I believe there are three major tasks with the next step.

    First, create a total cell. In other words, when there is a row with "Total" in it, I need to Sum those cells from D to L and place the value in M column.
    Second, total all the responses (these vary) across the different days.
    Third, using the totals create column segments that represent that data as a percentage.

    I have been fiddling around with my totals row, and found a few examples but it doesn't seem to work for me. The code I have been trying is in bolded red.



    The code is below.

    Please Login or Register  to view this content.
    The first way gives me a wrong number of arguments or invalid property error.

    This is a second way I tried:

    Please Login or Register  to view this content.
    Gives me essentially a range global failure error.

    I also tried this, based on a stack overflow forum post.

    Please Login or Register  to view this content.
    This way just freaks out.

    I have just now tried:
    Please Login or Register  to view this content.
    This doesn't give me a debug error message, but it does give me a formula error message of #NAME?. So, I know I am onto something. I just can't figure out the right combination of range(cell(row,col index) commentary to get it to work.

    I have been up and down the forums and also in my Walkenbach Excel 2010 book, but cannot seem to find anything that actually works.


    Help finding the correct formulation would be fabulous. Also, if anyone has best practices for how to sum the other rows with varied number of responses and lack of key words that would be awesome too.

    Thanks in advance for any and all insight!

    Rachelle
    Last edited by rkorinko; 09-04-2014 at 04:33 PM. Reason: Forgot to provide error messages!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Using Sum with range cell-variable referencing

    Hi rko,

    Try it this way:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    07-17-2014
    Location
    Arlington, VA
    MS-Off Ver
    2010
    Posts
    10

    Re: Using Sum with range cell-variable referencing

    Hi XLadept,

    Thanks! I knew I had to be close...

    It worked, but I am curious what the ".Resize(1,3)" actually stands for or does.

  4. #4
    Registered User
    Join Date
    07-17-2014
    Location
    Arlington, VA
    MS-Off Ver
    2010
    Posts
    10

    Re: Using Sum with range cell-variable referencing

    Also, I am sorry, but I seem to have gotten ahead of myself XLadept.

    The aforementioned code works in the sense that it populates the correct values, in a given instance.

    However, it does not recalculate when I change any cells. This is something that it has to be able to do; the gist is that my colleague will be able to create this "topline" prior to the start of a program and successfully update it until the program ends.

    Thanks for further insight!

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Using Sum with range cell-variable referencing

    Hi rkorinko,

    You're welcome and thanks for the rep!

    That's easily fixed:

    Please Login or Register  to view this content.
    Or -just throw Calculate in as a command wherever you need it

    * The resize changes the size of the range, in this case to 1 row and three columns

    it's like saying
    Please Login or Register  to view this content.
    Last edited by xladept; 09-05-2014 at 02:42 PM.

+ 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. Referencing a variable in an array range
    By ChainsawDR in forum Excel General
    Replies: 3
    Last Post: 01-09-2012, 09:22 AM
  2. referencing range w/ variable
    By dej222 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2009, 08:18 PM
  3. [SOLVED] Re: Help with referencing variable range
    By Tom Ogilvy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2005, 08:45 PM
  4. Help with referencing variable range
    By Cutter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2005, 05:20 PM
  5. [SOLVED] Re: Help with referencing variable range
    By Gary Keramidas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-04-2005, 05:10 PM

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