+ Reply to Thread
Results 1 to 24 of 24

Need help : Find a particular text and do summation till that point

  1. #1
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Need help : Find a particular text and do summation till that point

    I have just started learning VBA, mostly from online videos. Could someone help me with this task? workhorse.xlsx This is part of the bigger excel sheet. I would like to write a macro to find the column D6 based on the location of text 'committed total' . Then addup all numbers from E6 to V6 and write total in W6. Then add d6 and w6 and place it in X6.

  2. #2
    Forum Contributor
    Join Date
    10-19-2012
    Location
    chennai
    MS-Off Ver
    Excel 2013
    Posts
    134

    Re: Need help : Find a particular text and do summation till that point

    hi check with the below code

    Please Login or Register  to view this content.

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

    Re: Need help : Find a particular text and do summation till that point

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    I need to clarify, this is just small part of excel sheet, columns are added to the left of D as each month passes. Hence the referencing like [-17] or =SUM(E6:V6) will not work.

    The end of summation has to be identified based on column header not just absolute location of the cells ie. 'Committed Total'. In short I want to write a macro that selects the numbers between 'committed total' and 'Forecast Total'.

  5. #5
    Forum Contributor
    Join Date
    10-19-2012
    Location
    chennai
    MS-Off Ver
    Excel 2013
    Posts
    134

    Re: Need help : Find a particular text and do summation till that point

    you can find the header with match function in the heading array and form the header you try to make sum of 17 column this will work i think so..

  6. #6
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    The algorithm is clear in my head. But I do not know how to write the sytanx for it. Started learning VBA a week ago. I do have some experience with C++. I would be very grateful if someone could write the code for me, so that I can learn from it. I tried to find YouTube video for such an algorithm but couldn't find one.

    Thanks!

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

    Re: Need help : Find a particular text and do summation till that point

    Maybe:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    This works! Thanks alot. One more bit, how to extend this perform the same task on all the non-empty rows below?

    I haven't fully understood, how this code works. first time I am seeing things like Set Rng1 = Rows(2).Find("Committed Total", LookIn:=xlValues, Lookat:=xlWhole) Will have to do some reading on this! :D

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

    Re: Need help : Find a particular text and do summation till that point

    Try:

    Please Login or Register  to view this content.
    You can google or search threads for the Find Method in VBA.

  10. #10
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    First of all, thanks for this code! Another small issue is D is an absolute reference, shouldn't the location be referenced based on 'committed total' location?

    For i = 6 To Range("D" & Rows.count).End(3).Row

  11. #11
    Forum Contributor
    Join Date
    10-19-2012
    Location
    chennai
    MS-Off Ver
    Excel 2013
    Posts
    134

    Re: Need help : Find a particular text and do summation till that point

    SRY wrong comt
    Last edited by rajansettu; 08-11-2014 at 07:48 AM.

  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: Need help : Find a particular text and do summation till that point

    Assuming that you have the same amount of rows in each column then it wouldn't be an issue. It would do the same as:

    For i = 6 to Activesheet.usedrange.rows.count

    Looks like rajansettu came up with a different approach that may work as well.

  13. #13
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    here is the entire file, so you get an idea about what I am saying

    http://ge.tt/8GZxGuq1/v/0

  14. #14
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    here is the entire file, so you get an idea about what I am saying, I also have to total up all the numbers in top row

    http://ge.tt/8GZxGuq1/v/0

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

    Re: Need help : Find a particular text and do summation till that point

    Just to be consistent.

    Please Login or Register  to view this content.

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

    Re: Need help : Find a particular text and do summation till that point

    This is the modified code;

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    actually for i =7, in the complete excel file. row 6 is for summation of values in that column. how do i incorporate that summation?

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

    Re: Need help : Find a particular text and do summation till that point

    Can you attach a sample of your layout. To attach a sample in the Forum, push the button with the paperclip (or hit Go Advanced scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    Does this help?

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    Mappe1.xlsx

    row 6 is is just summation of column data

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

    Re: Need help : Find a particular text and do summation till that point

    Quote Originally Posted by oasafox View Post
    Attachment 338246

    row 6 is is just summation of column data
    Did you try the code posted in Post 18?

  21. #21
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    Yes. I did. But the last step is to add the columns up and place the total in row 6 cells. the headers in mappe1.xls will give you an idea

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

    Re: Need help : Find a particular text and do summation till that point

    Quote Originally Posted by oasafox View Post
    Yes. I did. But the last step is to add the columns up and place the total in row 6 cells. the headers in mappe1.xls will give you an idea
    Try:

    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    08-11-2014
    Location
    COlogne, Germany
    MS-Off Ver
    2010, 2013
    Posts
    29

    Re: Need help : Find a particular text and do summation till that point

    This is perfect! Thanks a ton! how to I reward you or give you karma points etc. ? And how to tag this post as SOLVED?

    Quote Originally Posted by JOHN H. DAVIS View Post
    Try:

    Please Login or Register  to view this content.

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

    Re: Need help : Find a particular text and do summation till that point

    You're welcome. Glad to help out and thanks for the feedback. To add points just click on the *Add Reputation on my last post. To mark the thread as solved see Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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. Sum till the column till the date match
    By ursanil in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-02-2014, 06:29 AM
  2. [SOLVED] Find Last Row till it hits blank record. ( Section break)
    By nironto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2013, 10:59 PM
  3. Index/Match to find Starting Point of Average, Ending Point of Average Variable
    By tgentry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-09-2012, 01:04 AM
  4. Find the last cell with text in columns D till H and autofils.
    By DaCasp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-06-2012, 05:14 PM
  5. find hours left from now till 8-2-08 12:22:00
    By SJDANIELS in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-31-2008, 06:59 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