+ Reply to Thread
Results 1 to 31 of 31

This VB code to hide a row is only working for one sheet, and not the entire workbook?

  1. #1
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hello,

    I have a script, that should be working on any sheet, since I have it in the workbook area.

    What it is supposed to do is, when I type the word done, in a field on any of the group worksheets (group1, group2 or group3), it automatically hides that row in that sheet, as well as that row in the overview sheet. The overview sheet, is a sheet that contains a paste link of each row from any of the 3 additional sheets. If I go to the group1 sheet and type the word done in any row, it hides that row in that sheet and the overview sheet, no problem. But, if I do the same thing in group2 or group3 sheet, the row itself hides in that sheet, but not in the overview sheet????

    Can someone look at this code and tell me what is wrong?

    I have also attached my file so you can see what I am trying to achieve.

    thanks so much!!
    babs


    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    I think I see the problem, but I do not know how to fix it....

    It seems the only rows hiding in the Overview sheet, when I get one to hide on the group1 sheet, is only working because it is the exact same row number on both sheets. So it is not the paste link that is connecting them for the hiding part?

    Is there a way around this, so what I do on one of the regular sheets, hides the same data row on the overview sheet?

    thanks!
    babs

  3. #3
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    ...........
    Last edited by ibabs; 07-20-2013 at 12:06 PM.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Try this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    try this variation which traces back to the correct cell on Overview sheet

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hi Alpha Frog!

    Well, it is hiding the correct row in the group sheet, when I put done in any field, and it is hiding the correct row in the Overview sheet...yay!!!

    The only thing it is not doing now, is, when I do the search in cell A1 to bring back a hidden row in a particular group sheet and it says un-done, where it once said done, it unhides that row in the Group sheet, and changes the word done to un-done,but it doesn't unhide that row in the overview sheet....not sure if that is a similar problem??

    Trying to find where to fix that last part in this code. Then this will be done!!

    Thanks for your help thus far and if you can see why it doesn't unhide in the overview sheet, I would greatly appreciate that.

    Here is my latest file enclosed with the new code.

    thanks
    babs
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    HI Andy,

    Alpha Frogs code worked for that initial problem...I do have one final issue here, and enclosed my latest file with the new code.
    If you have any insight to why a row un-hides OK using the search option built into the code, in the initial sheet, but does not un-hide in the over view sheet, I would really appreciate some help here with that. I just posted it in the previous post.
    Thanks!!
    babs

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    In cell A1, do you only type in a person's name from column C? If yes, are the names unique in each group?

  9. #9
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hello,

    Actually this is all dummy copy for something I am hoping/trying to accomplish.

    These rows will actually be names of projects, and have scheduled dates across the rows for when things are due on a particular job. There will be other information, like who is working on that job, and maybe what vendor we are using if we outsource something etc... Just trying to find a better way to keep track of things. The search is used to find any matching data in the name of the job cell (which is not in my dummy sheet example, but will be tied to one specific column).

    Each sheet (other than the overview one) represents a different department, and some jobs have the same name in each department, but they have different roles in that job.

    The overview sheet is merely to show every current job we are working on. This is why I needed something to hide a completed/done job. The list overtime would get unruly....eventually I will lock the overview sheet so it can only be sorted and filtered. And I will work only in the department tabs adding jobs and hiding them when done.

    I also plan on working on a way to auto-populate each job in the overview sheet, once it is added to any of the other sheets. So, I don't have to due the copy- paste link. But that is the dream..... Getting the hide and unhide part with the search, is the more necessary part.

    I hope that makes sense???
    thanks so much!!
    babs

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Works perfectly!!!!!!
    many many thanks!!!!

    gonna try to learn to auto populate now

  12. #12
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hi Alpha Frog!
    I just found one issue....sorry
    I was testing the ability to protect the overview sheet so no one could add or change any data there, only sort and filter, but when I took off the filter, all the hidden rows appear? Is there anyway to have the filter not bring back the hidden rows? Is that possible?
    thanks!!
    babs

  13. #13
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Quote Originally Posted by ibabs View Post
    Hi Alpha Frog!
    I just found one issue....sorry
    I was testing the ability to protect the overview sheet so no one could add or change any data there, only sort and filter, but when I took off the filter, all the hidden rows appear? Is there anyway to have the filter not bring back the hidden rows? Is that possible?
    thanks!!
    babs
    There is no built-in syntax for the autofilter to exclude the previously hidden rows. Its job is to hide\unhide rows.

    If one column had "Done" in it, or you tag a column with a value to indicate the row's hidden status, then you could just autofilter on that column when you want to re-hide the rows. In other words, incorporate a method to define and reset the rows that should be hidden.

    A whole other solution is to have code auto-copy all the visible data from the Group sheets to the Overview sheet whenever you activate the Overview sheet. Then you can AutoFilter that data any way you like.

    Put this code in the Overview worksheet's code module.
    Please Login or Register  to view this content.
    Put this in the ThisWorkbook code module.
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hi,
    First, thanks for getting back to this.....
    I put those 2 sets of code in-one in the overview worksheet and one in the workbook area.
    I got the following error, when I tried to hide (say done) to one of the sheets to start testing.
    Screen Shot 2013-07-20 at 6.22.21 PM.png
    any thoughts?
    babs

  15. #15
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Is the overview worksheet protected? If yes, add this. Change the password to suit.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 07-20-2013 at 06:58 PM.

  16. #16
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hi AlphaFrog,

    There is no security on the workbook....not yet anyway..
    I enclosed the workbook, because it still ash that error....

    If you can ..... take a look...then you can see where it freezes.

    thanks!!!!!!!
    babs new_testAlphaFrogCode_Rev3.xlsm

  17. #17
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Quote Originally Posted by ibabs View Post
    Hi AlphaFrog,

    There is no security on the workbook....not yet anyway..
    I enclosed the workbook, because it still ash that error....

    If you can ..... take a look...then you can see where it freezes.

    thanks!!!!!!!
    babs Attachment 251680
    Your new attached workbook worked for me as is.

    Maybe try this..
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hmmm??? The only thing I can think of is I am on a mac?
    Cause the minute I even opened up that file, I get this debug message. See attached.

    I guess what I could do, is use the one that was working and then after a filter, when all the done rows come back in the overview sheet, I could probably just filter to show all except those?? Or maybe I will protect the sheet from filtering and just allow sorting..That could be another option!

    It's a work around, but it will work!!!
    I feel bad that you have spent so much time on this....but I really appreciate all your help!!

    I thank you for helping me get that first part to work!!1

    It has to be a PC/Mac thing, and since I run a mac at work too, probably will be the same issue.

    thank you again for all your effort!!!
    Attached Images Attached Images

  19. #19
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    For future reference, start out your questions with the bit about having a Mac version.

    Try the code without the Autofilter lines.

    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    You are a genius!!!
    I am so sorry about the mac issue!!!! I will make sure to preface that in the future!!
    This is working great!!!
    I took the password off and did the filter and sorting and it was perfect!!!!
    Thanks so much!!!

  21. #21
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    You're welcome. I don't know why the .Autofilter code doesn't work on a Mac.

  22. #22
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    I have no idea?? I always assume code will be pretty safe between the two systems....I guess not. I am so excited and been studying your code. I am just learning VB script and taking an online class, but I have a very long way to go!!!

  23. #23
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    WOW!!!! it's not even my birthday!!! You didn't tell me you already did the auto-populate part
    That's amazing!!!!
    I added some test worksheets and saw how the name needs to go in the code for the name of each sheet


    Please Login or Register  to view this content.
    So, one last question....when I name the sheets new names (Although I could keep group* in front of the new name and it works fine), but if I wanted to make all unique names, is the best way to re-write the code something like this:

    Please Login or Register  to view this content.
    This doesn't seem to work, and I have tried to copy and paste that line and just add new names individually, and that doesn't work either. Do they need to be in {} or [] like a subset of sheet names????

    Seriously...that was quite the surprise..........

  24. #24
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    This would exclude the "overview" sheet and include all other sheet regardless of the name.

    If ws.Name <> "overview" Then 'This is case sensitive


    You could remove this If statement and loop trough specific sheets by name or by index number.

    For Each ws In Sheets(Array("bags", "camera", "design"))
    or
    For i = 2 to 4
    Sheets(i).Range("A6")....

  25. #25
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hi AlphaFrog....

    I actually did get it to work like this....

    Please Login or Register  to view this content.
    I would do that for all the sheets....although this is much cleaner.....so, I will now mess with this!!!

    Thanks so so so much for everything!!!!
    This is amazing!!!!

  26. #26
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hi AlphaFrog!!!

    I am back.....

    Ok, I am working finally on my live file and working on getting the code switched from my play one to the real one.
    I am at that part where we ended where I was trying to figure out how best to include all the tab names.....for some reson now, I can't get it to work....?? I know you had in the previous post mentioed a way to have it take care of all the tabs but the first one "Overview"..but I can't figure out how to use that one.... This was your suggestion.....
    For i = 2 to 4?????
    Sheets(i).Range("A6")....

    So, here was my line thus far, but it's giving me errors and I haven't put all the tab names in yet
    Please Login or Register  to view this content.
    I don't mind doing it the long way, but I just needed it to recognize all my tabs....Here was the original script: The tabs were refered to as Group and a number.....but now I need to put the real ones in.
    Please Login or Register  to view this content.
    Thanks!!!!!!!!!
    babs

  27. #27
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    From post # 24

    For Each ws In Sheets(Array("bags", "camera", "design"))

  28. #28
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hi AlphaFrog....

    I had tried that, but maybe something else is wrong..this is what I have:

    Please Login or Register  to view this content.
    Should I take the line out now that says:

    Please Login or Register  to view this content.
    I assume that comes out..but I am also getting a debug error on this line:

    Please Login or Register  to view this content.
    So not sure what the issue is????



    thanks!
    babs

  29. #29
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Hi AlphaFrog...
    Ok, I got the hiding and unhiding part to work....

    What is not working is the search part...I had to change the cell value from $A$1 to $F$1 (cause something was in cell a1 already)

    Here is the code....but it's not doing that cool unhide???

    Please Login or Register  to view this content.
    any thoughts?
    thanks!!!
    babs

  30. #30
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    Your recent code was copied from an earlier version that didn't work. Post #10 was the version you said worked.
    Last edited by AlphaFrog; 08-07-2013 at 11:58 AM. Reason: typo

  31. #31
    Forum Contributor
    Join Date
    05-07-2009
    Location
    cedar grove
    MS-Off Ver
    Excel 2003
    Posts
    133

    Re: This VB code to hide a row is only working for one sheet, and not the entire workbook?

    hmm...OK..still not working, but let me take all of this home and read through everything..Hopefully I will find that one thing
    Almost there!!!
    thanks........
    babs

+ 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: 20
    Last Post: 01-11-2014, 05:39 AM
  2. code not working for copied sheet in same workbook
    By banhisikha.basak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2013, 06:32 AM
  3. VBA to hide sheet in workbook and also reference in code
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-21-2011, 07:20 PM
  4. Code to hide Entire row based on criteria
    By ram in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-09-2006, 05:35 PM
  5. [SOLVED] Hide an entire row - Not working
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2005, 05:05 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