+ Reply to Thread
Results 1 to 13 of 13

Autosum column by searching through row 1 for the word total in first cell of the col

  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Autosum column by searching through row 1 for the word total in first cell of the col

    is there a way i can create a macro to Autosum a column by searching through row 1 for the word total or grand total in first cell of the column?
    Last edited by daillest319; 02-21-2012 at 03:17 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    Hi daillest319
    The SumIf function may well work...what's your data look like?
    Last edited by jaslake; 02-21-2012 at 01:37 PM. Reason: meant to say SumIf
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    The first row are the column names but total can be in column G one day and H another etc. So i want it to just sum the total of whatever column the word total is in row 1. so basiclly look for the word in row 1 and total the column from the last cell to cell 2 because cell one is always the column name.

    test.xls
    Last edited by daillest319; 02-21-2012 at 02:05 PM.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    Hi daillest319
    Try this code
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    this would work but the only problem the amount of rows in the workbook always changes and right now this is only giving me a total from three cells up. sometime it 50 rows something its 100 so the if it can go from the last cell up to the cell 2 it would be perfect.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    Hi daillest319
    Sorry about that...didn't adjust the formula
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    thank you so much for your help. I have one more question is it possible to make this for any worksheet instead of using With Sheets("test")? so i dont have to rename the worksheet test everytime. Thanks again.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    If it's ALWAYS the Active Sheet
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    Thank you so much it works perfect. i also wanted to use counta() on the coulmn where city is. can i just replace total with city and and =sum( with =counta(?


    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    there actually another problem it grabbbing cell one instead just stopping at cell 2
    for example it doing this =SUM(U1:U183) instead of =SUM(U2:U183)

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    Hi daillest319
    SUMIF works as previously written but COUNTA won't. This code should work for both
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-09-2012
    Location
    here
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    Thank you!!!! Works perfect

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Autosum column by searching through row 1 for the word total in first cell of the

    Hi daillest319

    You're welcome...glad I could help.

+ 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