Macro to Filter/Save As Not Working

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • Hello,


    I wrote the following macro, and it worked for a while, then I had to make a tweak and it is no longer working. The goal is to hide certain rows, open that filtered view in a new workbook, and save that workbook to the user's desktop:



    Not sure where I went wrong -- help appreciated!
    Thanks,
    Corcelle

  • Re: Macro to Filter/Save As Not Working


    What line is giving you the error? If no error what is currently happening that makes it not work?

  • Re: Macro to Filter/Save As Not Working



    I think your issue is that your code does nothing with the values that are copied. So you do all of the hiding without actually putting the new values in a new workbook.


    *Edit fixed an error

  • Re: Macro to Filter/Save As Not Working


    Hi,
    There is no error -- the macro executes. However, I want the new page to only show certain rows (which is why I have the Hide commands), but it is showing all of the rows.)

  • Re: Macro to Filter/Save As Not Working


    Also you might want to consider changing your end row to be more dynamic to your dataset. I usually use something like this:


    Code
    endrow=cells(rows.count,1).end(xlup).row


    Just a piece of friendly coding advice :)


    I fixed an error in the code, can you try it again?

  • Re: Macro to Filter/Save As Not Working


    Caught one more error that is not excluding the hidden cell when copying (sorry I was doing it by freehand before) I just tested this one and it works:


  • Re: Macro to Filter/Save As Not Working


    Thank you for your help. It is giving me an error on the following line, saying I cannot change part of a merged cell.


    Selection.SpecialCells(xlCellTypeVisible).Copy Destination:=NewWB.Sheets(1).Cells(1, 1)

  • Re: Macro to Filter/Save As Not Working


    is it possible for you to attach your sheet? Where is the merged cell in your data set?

  • Re: Macro to Filter/Save As Not Working


    Sorry for the delay. Try this:


    I adjusted some code and your begin row number.

  • Re: Macro to Filter/Save As Not Working


    Sorry it took me a while to respond to this. I replaced my code with your code above, and it created a new file called MF Tasks Export and saved it to the Desktop, but the file is blank/has no content.


    Any thoughts?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!