+ Reply to Thread
Results 1 to 18 of 18

Macro to sort and insert text based on a cell's value, and other small things.

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Macro to sort and insert text based on a cell's value, and other small things.

    Workbook attached.

    First thing we do is remove duplicates only using column "A"
    Then we create a column "G" titled "Days Since Payment" and insert the formula "=today()-XX"
    Then we create a column "H" titled "Group"
    "H" has the groups, "0-33","34-60","61+","Never". Whichever group the value of "G" falls in between is what goes into "H"
    Then column G is column by smallest - largest.

    This worksheet will be hundreds of rows deep.

    Then we insert a pivot table with Account Queue Name/Group in the Rows and Count of Days in values.

    I could record a macro that does most of these, other than the grouping I think, but with the # of rows involved, I figure i'll bog my computer with just a recorded macro.

    Workbook has three sheets. a "raw" where you can see what we start with and should be able to track with my steps, the the Finished sheet that shows the results and finally the pivot table.
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    This might get you started... I didn't get the pivot table.


    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    Thank you so much for doing that. I do receive a #NAME? error when I attempted to run it on my example workbook. It does stop at the end of the last row, but has that error

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    I'm not getting any errors.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    So WTH! lol

    So I modified it a little bit we don't have to worry about the sheet name. But i think that does it! As far as the pivot, I did a recorded macro and tried to work with another macro to combine them. One issue I know is the "source data" wouldn't be DCMR. I would like it to just be the active worksheet.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    If I adjust the vba at all, even undo back, I get the #NAME? error

  7. #7
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    So Mike, this is what I have, and it works perfectly when I run it inside your workbook. But if I move/copy that raw sheet out of yours, then this macro and yours fails.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    Sorry mike, I didn't see your response. It is the same error as my first post. #Name? in the Group column

  9. #9
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    I don't get any error's What line of code does it error on? Are all the cells filled with Name?

    Nothing to do with your errors but you need to add a . for the columns. Being it is within the with ws

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    It isn't an error with the code itself. The error is what shows up in the group column. How down that column it will have the #NAME?

    The macro runs without issue.

  11. #11
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    Does every cell in the Column have #NAME? What value/values? should be in there.

  12. #12
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    Hey Mike, ever cell has it in the column, but it does stop at the last row. And it should be the value based on the group. You wrote the macro for it, it is the 0-33, blah, 61+ that is put into that column. It is the same error as my post #3 and the other thread that was closed I started that you comment on. That has the two workbooks for easy comparison and the better explanation too.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,552

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    Try
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    Subscript out of range.

    Please Login or Register  to view this content.
    Seems I have to create another sheet and name it finished?

    Is that easier than fixing the one mike helped with? It is setup for autofit and does the pivot and everything.

  15. #15
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    *edit.

    Mike, idk what it is but it seems to be workbook driven. If I copy the data from your workbook into this other workbook it doesn't work, but it does work if i copy the other data into your workbook.

    Since this is not an issue with my original question, and your macro works. I am reposting a question tied directly to why a VBA would work in one but not another. I am marking this as solved as you did amazingly to help!
    Last edited by taylorsm; 02-27-2017 at 10:15 AM.

  16. #16
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    Where are you placing the code at into the other workbook. Code needs to go into a Standard Module and not a sheet Module.

  17. #17
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    I have it saved into PERSONAL.XLSB and I have ran the code from that location on both and resulted in the aforementioned issues.

    But I have it under "MODULES" I do insert>module

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,552

    Re: Macro to sort and insert text based on a cell's value, and other small things.

    Quote Originally Posted by taylorsm View Post
    I have it saved into PERSONAL.XLSB ....
    Please Login or Register  to view this content.

+ 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. Need help with macro to auto sort based on two things
    By smanonfire in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-08-2017, 05:01 PM
  2. Macro to insert text into a cell based on another cell's number
    By ahovancsak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2015, 12:47 PM
  3. [SOLVED] Sort macro doing squirley things to my spreadsheet!
    By amoraali in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2015, 05:37 PM
  4. Macro needed to insert certain text after a specific cell value, sort,filter, hide and sav
    By scarlettw123 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 02-03-2015, 07:41 PM
  5. [SOLVED] Event Macro to insert text in cell based on input of another cell
    By nplouffe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-08-2012, 11:54 AM
  6. Need Help w/Macro That Will Insert Column Based on Specific Text in a Given Cell
    By pb6933944 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-23-2012, 12:23 PM
  7. codign several small things in VBA
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2011, 10:39 PM

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