+ Reply to Thread
Results 1 to 13 of 13

Macro for grouping/subtotal and row fill by column text value

  1. #1
    Registered User
    Join Date
    08-03-2015
    Location
    60606
    MS-Off Ver
    2010
    Posts
    7

    Macro for grouping/subtotal and row fill by column text value

    test2.xlsx

    Hi all! I need help creating a macro that does the following:
    *Inserts a row above each change in description (Column B);
    *puts the "description" in that new row;
    *fills those rows with RGB(141, 180, 226);
    *bolds the text.

    I created this macro to subtotal based on description and adds the count, and then fills the cell with the word "count":

    Please Login or Register  to view this content.
    It doesn't seem like the prettiest thing, so I would love some help. I was also trying to play around with conditional formatting and tried to add "=ISNUMBERSEARCH(" * Count * ",$A1:$Z1000))" to the macro, but it won't work.

    Is there a better way to sort/group based on changes in description as I described other than subtotal? The rows will change drastically over time/between documents, so this was the only way I could figure out to do it. I don't need the "count" of each, just the row inserted above, and this is all I could think of.

    Please help!
    Last edited by toph423; 08-03-2015 at 10:46 PM.

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Macro for grouping/subtotal and row fill by column text value

    There are always other ways, but what you have is probably fine. If you're going to run it frequently, you would need to add a line to remove existing subtotals first. You could add a line in your If statement to change "description Count" to "description". You could also add a line to delete the count, but then Excel won't recognize it as subtotals, and when you remove the subtotals it won't remove those rows. If you choose that route, then after removing the subtotals, add a loop to delete those rows.
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Registered User
    Join Date
    08-03-2015
    Location
    60606
    MS-Off Ver
    2010
    Posts
    7

    Re: Macro for grouping/subtotal and row fill by column text value

    Thanks for the info!

    I slightly tweaked it to this, but ran into a problem:

    Please Login or Register  to view this content.
    How do I get the interior color to be RGB(141, 180, 226)? Is there any other way to write this?

    Thanks for any help!

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Macro for grouping/subtotal and row fill by column text value

    I haven't worked much with coding for conditional formatting. I could spend some time experimenting, but maybe someone else could jump in on this one?

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

    Re: Macro for grouping/subtotal and row fill by column text value

    Does this help?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-03-2015
    Location
    60606
    MS-Off Ver
    2010
    Posts
    7

    Re: Macro for grouping/subtotal and row fill by column text value

    How did I just see this reply?!? That is amazing, thank you! Though, is there a way to insert the filled row above each new category? Like, inserting the heading from B above the first B value in that "group," so that it is more obvious where each new grouping starts (for example, putting "Banking" above the first banking from B2, "Contracts" above B5, "Corporate Law" above the first in B6, etc.? Ideally, those headings would also go in the A column.

    I'm also now being asked to wrap the text on the entire spreadsheet; repeat $1:$1 at the top of each page; and bold all of column A. If anyone could also help figure out how to add that in, I would much appreciate it!!!!

  7. #7
    Registered User
    Join Date
    08-03-2015
    Location
    60606
    MS-Off Ver
    2010
    Posts
    7

    Re: Macro for grouping/subtotal and row fill by column text value

    I've been trying to get the insert a row above each change in B to work (like a header for each "group" of B), but I can't figure it out. Is there something I could add to that macro to make that work?

  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: Macro for grouping/subtotal and row fill by column text value

    Sorry for the late reply. Try:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-03-2015
    Location
    60606
    MS-Off Ver
    2010
    Posts
    7

    Re: Macro for grouping/subtotal and row fill by column text value

    Thanks, that's great!

    I was wondering if there is a way to move the header/value that's created for each new row (from the change in B) into column A, or merge the rows in A and B with that group header?
    Last edited by toph423; 08-27-2015 at 01:15 AM.

  10. #10
    Registered User
    Join Date
    08-03-2015
    Location
    60606
    MS-Off Ver
    2010
    Posts
    7

    Re: Macro for grouping/subtotal and row fill by column text value

    So that wasn't correct. Any thoughts, please?
    --
    Ok, I'm trying to figure this out myself, but don't have a computer at the moment to test it. Could I change it to this? I've been having fun trying to parse the code and what each piece means. Haha.

    Please Login or Register  to view this content.
    Last edited by toph423; 08-28-2015 at 01:02 AM.

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

    Re: Macro for grouping/subtotal and row fill by column text value

    Try:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-03-2015
    Location
    60606
    MS-Off Ver
    2010
    Posts
    7

    Re: Macro for grouping/subtotal and row fill by column text value

    This is perfect! Thank you!

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

    Re: Macro for grouping/subtotal and row fill by column text value

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

+ 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. Using a macro on workbook1 to create a button in wb2 and assigning macro "wb2!macro"
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2014, 11:39 AM
  2. [SOLVED] Macro to merge duplicate rows unique values - current macro not working
    By aimeecrystalaid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-06-2013, 03:42 PM
  3. [SOLVED] Macro to show Which macro didnt work in a nested macro
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 03:21 AM
  4. Perform macro "on open" specific file- store macro in Personal Macro Workbook?
    By thompssc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 12:38 PM
  5. lookup macro, solver macro, realtime macro
    By xelhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2011, 06:14 PM
  6. Cannot find macro error when running a macro from a macro in a diffrent workbook.
    By Acrobatic82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2010, 09:22 AM
  7. Macro calling another Macro: "The macro 'Personal.xls!FindChar"
    By William Benson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2005, 09:05 AM

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