+ Reply to Thread
Results 1 to 15 of 15

A macro wich will delete (or hide) rows in one tab under conditions from other tab

  1. #1
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    A macro wich will delete (or hide) rows in one tab under conditions from other tab

    Hi guys, as I'm not really familiar with VBA, this is really hard for me to figure out how to write macro.

    I already have a macro, which I need to change (or to just have new one), because need to change the process. What I have Is a button, which delete rows with name "invoice" in specific column.

    What I need right now (as I needed to make some changes in the tab 1) is a macro which automatically will remove/hide rows from tab 1. The difference now is that I need to follow what is in Column A, Sheet1 - not all invoices must be deleted. Sometimes I would need to delete Black, sometimes Red, and sometimes both. So I was thinking of having combo box instead of a button, but have no clue how to do this. I already made a new list (old was just "invoice" or "non-invoice") and put a combo box. But tried to change macro I already have and did not work.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    Do you really need Sheet2? You could add a drop down list in Sheet1 in cell A1 (or any cell of your choosing) where you could select Red Invoice, Black Invoice, Black+Red Invoice or All standard that would delete the appropriate rows. Would this work for you?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    Yes, as this file is just an example. I need this for a different file which looks not as simple as this, but contains confidential info, so just could not send it.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    Would it work for you if instead of a combobox in Sheet2, we use a data validation drop down list from which you can select an option? Also, what is the purpose of "New" and "Old"?

  5. #5
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    It would be good too, but just thought the "new" approach would work better. "OLD" is what I already have and "NEW" is what I wanted to work. So is it possible to leave a standard dropdown list to work as I have mentioned?

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    Try the attached file. Make a selection in cell J1 of Sheet2.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    It's not working. There is a pop-up as is the attachment. Attachment 659660

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    It works for me. Your link doesn't work. What does the pop-up say? Try the attached version. It's in a different format.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    Still not working for me. The pop-up says: Run-time error '1004': Method 'Autofilter' of object 'Range' failed. And if I click "End" and want to see what happens in tab1, everything is hidden each time.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    The macro works properly for me without any errors. Are you trying the file I posted or are you trying the macro on a different file?

  11. #11
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    I was trying on the files you have attached.

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    I still can't reproduce the error you are getting. Please attach a copy of the file that is giving you the error.

  13. #13
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    Hmm.. I just download the file open it and try to perform the action. that's it.
    Attached Files Attached Files

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    I opened the file, made a selection in J1 of Sheet2 and it worked properly. If it's not working for you, I don't think that I can offer any more help.

  15. #15
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    Re: A macro wich will delete (or hide) rows in one tab under conditions from other tab

    Ok, thanks anyways!

+ 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. VBA/Macro - Delete rows if 2 conditions are met
    By Nikhil76 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-19-2018, 03:18 AM
  2. [SOLVED] Need a macro to delete rows based on multiple conditions
    By WorkAccount2 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-30-2017, 12:33 PM
  3. Macro to Hide or Delete Rows is not Consistance -- Please help
    By sspiel4 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2016, 04:32 PM
  4. [SOLVED] Macro to Delete Rows based on Specific Conditions
    By stockgoblin42 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-28-2013, 05:29 PM
  5. Macro to delete rows with conditions
    By adray13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2012, 11:05 AM
  6. [SOLVED] Macro required to delete rows with multiple conditions
    By bigband1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2012, 03:53 AM
  7. macro to delete (not hide) rows and resort
    By jrtaylor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2009, 06:09 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