+ Reply to Thread
Results 1 to 5 of 5

VBA code to sum a range based on criteria in two separate columns

  1. #1
    Registered User
    Join Date
    09-11-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2002, 2003,2007
    Posts
    39

    VBA code to sum a range based on criteria in two separate columns

    My apologies for the vague Title in my original post.

    I've have the following code:

    Please Login or Register  to view this content.
    Here is what I'm trying to accomplish after the Stop in the above code (BTW, I run the code from VPP.xls, worksheet Travel Time).

    Based on the Street name in VPP.xls, worksheet Travel Time, I want to find the distance between the streets from TT.xls worksheet, Travel Time Results, and report that in column E (the table is filled out how it should look after the code is run).

    For example, I want the distance between Street A and Street F WB. It should return a value of 5.2 (5238.9/1000).

    I've been using the following excel formula in column E in VPP.xls, but I want the code to actually just report the value in the cell. I can't figure out how to use the application.worksheet function, which I may not be able to do because of the : contained within the formula.

    Please Login or Register  to view this content.
    Similar to finding the distance, I want to find the A and B times between those same streets and put that in the appropriate A and B columns. I imagine that would be similar code to the above, so if I can just figure that part out, I can get the rest.

    Thanks

    J

    Again, I apologize for my vagueness originally.
    Attached Files Attached Files
    Last edited by new.vbacoder; 11-17-2010 at 01:38 PM.

  2. #2
    Registered User
    Join Date
    09-11-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2002, 2003,2007
    Posts
    39

    Re: Help with some VBA code (copy multiple cells, sum values based on 2-column criter

    Removed post.
    Last edited by new.vbacoder; 11-14-2010 at 12:28 AM.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Help with some VBA code (copy multiple cells, sum values based on 2-column criter

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    09-11-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2002, 2003,2007
    Posts
    39

    Re: VBA code to sum a range based on criteria in two separate columns

    Not sure if this is the best way to do it, but it works.

    Please Login or Register  to view this content.
    If someone out there has any better ideas, maybe instead of using formulas, using just straight VBA code, it would be good to see how else this can be accomplished.

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VBA code to sum a range based on criteria in two separate columns

    Maybe this is a viable approach:
    Please Login or Register  to view this content.
    Actually I don't think it works correctly, but you get the idea (perhaps).
    Last edited by StephenR; 11-17-2010 at 02:44 PM.

+ 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