+ Reply to Thread
Results 1 to 13 of 13

Sum Values From Row Dependent on Adjacent Cell Value

  1. #1
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Sum Values From Row Dependent on Adjacent Cell Value

    Hi, I wonder whether someone may be able to help me please.

    I'm trying to perform the following on the last row of a data table.

    • Find the first blank cell in column B starting from row 8, then
    • Insert the text value "Summary of B&C, BT, E&C, PT & PD" into this row, i.e creating a 'Summary Row' then
    • If the cells in column B contain the values "B&C, BT, E&C, PT or PD" sum the values on the same row from columns C:H and paste the totals in the 'Summary Row'

    I've put the following code together which finds the first blank cell and adds the text value "Summary of B&C, BT, E&C, PT & PD". I've then started to add the code which searches for the desired values, but I can't work out how to sum the adjacent values and add the totals to the 'Summary Row'.

    Please Login or Register  to view this content.
    I just wondered whether someone may be able to look at this please and offer some guidance on how I may complete this.

    Many thanks and kind regards

    Chris

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Hi @John H. Davis, thank you for taking the time to reply to my post.

    I've tried the code you kindly sent and the text value is placed in the correct cell, but unfortunateky the sum function doesn't work, with the cells on the 'Summary Row' only showing zero.

    Many thanks and kind regards

    Chris

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Chris: Can you attach a sample where the code does not work. I only tested on some makeshift data.

  5. #5
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Hi, please ignore me, the code works perfectly, thank you!

    Because the information is confidential, I shortened the values I needed to search for. When I used the code you kindly sent, I forgot to change these values, my sincere apologies.

    Many thanks and kind regards

    Chris

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    You're welcome. Glad to help out and thanks for the feedback.

  7. #7
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Hi, I wonder if someone may be able to help me please.

    John H. Davis kindly helped me with the above issue I was having. I initially tested the code and all seemed fine, but further testing has revealed that the summary row figures aren't entirely accuarte. I think it may be because these figures are rounded up or down, so I've been trying to find a way to show the total figure in the format 0.00.

    I've tried amending these lines:

    `z = z + Cells(i, y).Value` and
    `z = z` to

    `z = z + Cells(i, y).Value(Format(z, "#,##0.00"))` and
    `z = z (Format(z, "#,##0.00"))`

    Without success.

    I just wondered whether someone could possibly look at this please and let me know where I'm going wrong.

    Many thanks and kind regards

    Chris
    Last edited by hobbiton73; 11-20-2014 at 04:11 AM.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Maybe:

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Hi @John H. Davis, thank you very much for taking the time to reply to my post with the change in code. The format change works great, but unfortunately doesn't change the problem with the 'Total' figures shown. For example in my first column the total should be 12.35, but the code shows the total as 13, so I'm not sure whether it isn't the original code that's the issue. Is there perhaps anyway please, you could suggest a method of making the changes(s) to make the sum total the correct figure?

    Many thanks and kind regards

    Chris

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Can you attach a sample with some dummy data?

  11. #11
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Hi John H. Davis, I'm sorry for taking a little while to get back to you, but please find attached the sample file.

    Many thanks and kind regards

    Chris
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Try:

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: Sum Values From Row Dependent on Adjacent Cell Value

    Hi @John H. Davis, thank you very much for taking the time to revisit this, it works great.

    May I ask please, could you possibly add some comments to the code. I understand some elements of this not all.

    Many thanks and kind regards

    Chris

+ 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] VBA help needed to Fill cell values based on Adjacent Cell values
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-06-2014, 07:08 AM
  2. Macro to find all specific values in column and replace adjacent cell values
    By dblock02 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2013, 06:03 AM
  3. Replies: 1
    Last Post: 07-08-2013, 09:42 PM
  4. Data Validation List - Dependent on Adjacent Cell - Value from Unsorted List
    By justforthis1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-26-2013, 12:24 PM
  5. Adding cell values that are dependent on adjacent cell values
    By globulous in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-27-2009, 10:37 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