I have a word "MISC" on column C, can someone write me a vba code to hide ALL rows that do not contain that word?
I have a word "MISC" on column C, can someone write me a vba code to hide ALL rows that do not contain that word?
Why not just use the built in Filter?
Please Login or Register to view this content.
HTH
Regards, Jeff
I found this link https://www.ozgrid.com/forum/forum/h...pecified-value
bu it hs a name range, and I have it from row 2 to row 652 (its dynamic rows)
Please Login or Register to view this content.
actually the word is "NC" on column c
so I changed the code tobut it hides everything.Please Login or Register to view this content.
Please add a representative sample to build from with a clear before and after.
Also, turn on the filters, then turn on the macro recorder and record what you filter. The code will be produced.
this code works:
but how come it takes so long? its goin to every cell, is thre a quicker way please?Please Login or Register to view this content.
how do I unhide it? and reverse everything?
sorry never mind,i just grab a copy and put it back .
Last edited by chubbychub; 11-22-2018 at 03:45 PM.
Yes, use the built in filter feature or use the code to filter.
If you use the above, you are looping thru all the cells, whereas, the filter code is a one shot filter.
That's up to you and how you want the user to interact with your spreadsheet. What do you want to happen? In other words, what action would you expect the user to take to initiate the hide/unhide?
I don't know your spreadsheet.
A sample spreadsheet can always help too...
the below code works, but it loops thru each cell, however I think I can deal with the wait, how can I put everything back after its printed?
I have created a button to run that macro, but would like if possible, after that sub, it can unhide everything back.Please Login or Register to view this content.
Last edited by chubbychub; 11-22-2018 at 05:06 PM.
Try...
Please Login or Register to view this content.
Cells.EntireRow.Hidden = False , I tried adding the code at the bottom and it didn't worked.
i have been working all nite on it, and this is how far i got, but i am getting and error:
plese help so i can go to sleep. thank you.Please Login or Register to view this content.
When you hit debug, what line shows the error?'
Can you post a sample test workbook?
this code works, i was trying to make a separate line (i used macro recorder)
but i don't know what the difference is in between them both.Please Login or Register to view this content.
In this line of code above, you have broken the string. So, when you rewrite it too...Please Login or Register to view this content.
...it is now a continuous thought in the VBA language.Please Login or Register to view this content.
Also, I see as a difference...
This is good. You have to select the cells before you can act on them, however, you should be able to rewrite that as...Please Login or Register to view this content.
http://www.tushar-mehta.com/excel/vb...acro_recorder/Please Login or Register to view this content.
Very rarely in VBA do you have to select something to do something to it.
Last edited by jeffreybrown; 11-23-2018 at 07:03 PM.
Thank you jeffreybrow!!! that works, and i understand now. thank you very much again, thread marked as solved and rep added! thanks.
You're welcome and thanks for the rep.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks