+ Reply to Thread
Results 1 to 15 of 15

Revise marco so searched output is in new workbook plus search 2 sheets, add headers

  1. #1
    Registered User
    Join Date
    04-23-2020
    Location
    NYC
    MS-Off Ver
    MS Office 365 (2019)
    Posts
    8

    Question Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Hi All,


    I have used the following macro to create a report based on criteria. Currently, it outputs the results to a sheet labeled "Report". I need to revise the code to add some additional aspects.


    1. I would like the output to be to a new workbook.


    2. The macro as written only searches the sheet "HOTLINE" and returns the rows that have the search criteria "Unqualified Lead" in Column A. I would like for it to search 2 sheets: HOTLINE and WEBINAR for the same search criteria.

    3. I would like for the output to be in a new workbook with two sheets: HOTLINE AND WEBINAR and use the headers from the original tabs for the outputted rows



    Could I get some help on how to revise the code to achieve this? The original code is below:

    EDIT: I've attached a sample file!



    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by tseb3; 04-27-2020 at 08:43 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Hi tseb3...

    Welcome to the forum...

    In future, always upload a sample file of your actual setup....See Yellow Banner above...
    I do not have a sample file of yours...but this will give you an idea...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Registered User
    Join Date
    04-23-2020
    Location
    NYC
    MS-Off Ver
    MS Office 365 (2019)
    Posts
    8

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Thanks so much for replying. My apologies on missing that step. I've since attached a sample! I really appreciate the help. The more I though it through, I realized it would be more efficient if the macro run as follows:

    1. I would like the output to be to a new workbook.


    2. The macro as written only searches the sheet "HOTLINE" and returns the rows that have the search criteria "Unqualified Lead" in Column A. I would like for it to search 2 sheets: HOTLINE and WEBINAR for the same search criteria.

    3. I would like for the output to be in a new workbook with two sheets: HOTLINE and WEBINAR and use the headers from the original tabs for the outputted rows from each original sheet. Basically its like a summary report of the search criteria only.

    THANK YOU SO SO MUCH. I've been banging my head trying to figure it out for days but I'm a fairly beginner user.

  5. #5
    Registered User
    Join Date
    04-23-2020
    Location
    NYC
    MS-Off Ver
    MS Office 365 (2019)
    Posts
    8

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Quote Originally Posted by sintek View Post
    Hi tseb3...

    Welcome to the forum...

    In future, always upload a sample file of your actual setup....See Yellow Banner above...
    I do not have a sample file of yours...but this will give you an idea...
    Please Login or Register  to view this content.
    Thanks so much for replying. My apologies on missing that step. I've since attached a sample! I really appreciate the help. The more I though it through, I realized it would be more efficient if the macro run as follows:

    1. I would like the output to be to a new workbook.


    2. The macro as written only searches the sheet "HOTLINE" and returns the rows that have the search criteria "Unqualified Lead" in Column A. I would like for it to search 2 sheets: HOTLINE and WEBINAR for the same search criteria.

    3. I would like for the output to be in a new workbook with two sheets: HOTLINE and WEBINAR and use the headers from the original tabs for the outputted rows from each original sheet. Basically its like a summary report of the search criteria only.

    THANK YOU SO SO MUCH. I've been banging my head trying to figure it out for days but I'm a fairly beginner user.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    I would like for the output to be in a new workbook with two sheets: HOTLINE and WEBINAR
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-23-2020
    Location
    NYC
    MS-Off Ver
    MS Office 365 (2019)
    Posts
    8

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Quote Originally Posted by sintek View Post
    Please Login or Register  to view this content.
    Sintek- thank you again. When I applied the above code, I get a "AutoFilter method of range class failed" error. I've attached a sample Excel in my original post if that helps.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    No need to quote entire posts...It just clutters the thread...Code works with your sample file provided...
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-23-2020
    Location
    NYC
    MS-Off Ver
    MS Office 365 (2019)
    Posts
    8

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Understood. Thanks for mentioning it.

    How can I edit the code to include the first 2 rows of each sheet in the output? The 2nd row was the column heading and I forgot to mention it.

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    @tseb

    Please don't quote whole posts -- it's just clutter.*If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Just click on the reply button, not the reply with Quote.

  11. #11
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Change this snippet...
    Please Login or Register  to view this content.
    To...
    Please Login or Register  to view this content.
    If this answers your initial question...Please mark thread as solved...Tx for adding rep +
    Last edited by sintek; 04-25-2020 at 04:52 AM.

  12. #12
    Registered User
    Join Date
    04-23-2020
    Location
    NYC
    MS-Off Ver
    MS Office 365 (2019)
    Posts
    8

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Sintek - I updated the code and it works perfectly on the sample file. However, when I apply it to my working file, I get "Run-time error '1004': AutoFilter method of Range class failed"

    The only difference from the sample file I provided is that my working copy has 10+ sheets and that the two searched sheets "hotline" and "webinar" have data validation in certain columns (choosing from a drop-down list). The column A referenced in the code is a one of those data validation columns. Could that be throwing off the code?

    I've attached an updated sample (with your code as well).
    Attached Files Attached Files

  13. #13
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    That is because you changed the data to a listobject...Change back to range and it works...
    Attached Files Attached Files
    Last edited by sintek; 04-27-2020 at 04:48 AM.

  14. #14
    Registered User
    Join Date
    04-23-2020
    Location
    NYC
    MS-Off Ver
    MS Office 365 (2019)
    Posts
    8

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    Works! Thank you very much again for all your assistance!

  15. #15
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Revise marco so searched output is in new workbook plus search 2 sheets, add headers

    All Good...

+ 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. Replies: 7
    Last Post: 02-13-2017, 04:51 PM
  2. [SOLVED] Any Faster Way to Copy/Paste this range? (I have searched and searched and searched)
    By liquidmettle in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-12-2015, 02:33 PM
  3. Merging All the sheets from different workbook , provided the headers are same.
    By Praveenk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2015, 07:50 AM
  4. [SOLVED] Macro to search all sheets and return corresponding rows of searched value
    By amar05 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-19-2013, 01:56 AM
  5. Search multiple workbook headers and copy column entries to another workbook
    By R3n3gad3-XtC in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2012, 12:47 AM
  6. Replies: 0
    Last Post: 11-29-2012, 06:37 AM
  7. Auto filter multiple columns matching with searched headers
    By gotovamsee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2011, 03:20 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