+ Reply to Thread
Results 1 to 7 of 7

this workbook code to unhide rows

Hybrid View

mardyl this workbook code to unhide... 12-18-2011, 06:14 PM
Richard Buttrey Re: this workbook code to... 12-18-2011, 06:22 PM
mardyl Re: this workbook code to... 12-20-2011, 11:01 PM
Richard Buttrey Re: this workbook code to... 12-21-2011, 06:58 AM
mardyl Re: this workbook code to... 12-21-2011, 02:39 PM
Richard Buttrey Re: this workbook code to... 12-21-2011, 02:55 PM
royUK Re: this workbook code to... 12-21-2011, 09:15 AM
  1. #1
    Registered User
    Join Date
    12-04-2011
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    22

    this workbook code to unhide rows

    I have a sheet in a workbook with some rows hidden.
    Is there any way I can add code to that sheet to unhide all rows when I want to close the workbook ?
    Can somebody help me with that ?j

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: this workbook code to unhide rows

    Hi,

    Use the Workbook_BeforeClose event and add the following instruction


    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Range("A1:A10").EntireRow.Hidden = True
    End Sub
    adjust the rows 1:10 as necessary
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    12-04-2011
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: this workbook code to unhide rows

    Hi Richard
    thanks a lot for your help. It was really very useful. I do appologize for late reply, but yo see, I am a ship's captain, and currently I am on board of a vessel, have rather limited access to internet, only in some ports. Now I will have internet for next 2-3 days and after that nobody knows when.
    Basis on your reply I was able to modify the code to suit my needs.
    I just wonder if you could help me with another problem, the code should be send to other users. Copies of their workbooks are protected, same as VBA projects.
    I would like to create a code which would unprotect the VBA project on user worbook, add the code to the workbook, and protect it back.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: this workbook code to unhide rows

    Hi,

    I wonder if an ocean roving ship's captain is the first for this forum.

    I occasionally get into trouble here for letting some forum rules breaches slip through, and sadly I fear your request about automatically unprotecting a VBA project probably breaches this particular rule.

    As it happens I don't believe you can do this anyway. If a VBA project is unlocked then you can add module code programatically but not if it is locked. Chip Pearson's VB Editor site http://www.cpearson.com/excel/vbe.aspx
    seems to confirm this and if Chip says it can't be done then that's good enough for me.

    His site will hopefully give you ideas about adding modules or procedures programatically, but if you need a precis version then just post back. I have one routine that I use from time to time whereby you can send a .bas code file to the user, along with an 'Updater' Excel macro template which prompts the user to choose the object workbook and then the .bas file, and then adds the .bas file to the object workbook.

    Regards

  5. #5
    Registered User
    Join Date
    12-04-2011
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: this workbook code to unhide rows

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    I wonder if an ocean roving ship's captain is the first for this forum.

    I occasionally get into trouble here for letting some forum rules breaches slip through, and sadly I fear your request about automatically unprotecting a VBA project probably breaches this particular rule.

    As it happens I don't believe you can do this anyway. If a VBA project is unlocked then you can add module code programatically but not if it is locked. Chip Pearson's VB Editor site http://www.cpearson.com/excel/vbe.aspx
    seems to confirm this and if Chip says it can't be done then that's good enough for me.

    His site will hopefully give you ideas about adding modules or procedures programatically, but if you need a precis version then just post back. I have one routine that I use from time to time whereby you can send a .bas code file to the user, along with an 'Updater' Excel macro template which prompts the user to choose the object workbook and then the .bas file, and then adds the .bas file to the object workbook.

    Regards

    Hi,
    I am not sure if my request is a breach of forum rules. I did not ask how to modify VBA project without password.
    I just wanted to create a code whch would unprotect the code after providing proper password and then protect it again with the same password, the password is known only to me, and I want to keep it that way. it is like providing the code for a worksheet: ActiveSheet. Unprotect " ********"
    Some time ago I created acocounting system for ships in our fleet. On some sheets I used activex controls, there was also an option,to,hide empty rows. All worked fine untill company changed Office 2003 toOffice 2010 and problem started, when you hide rows containing an activex control, savel it, close and open again, all activex controls disappear. In fact they are stil there, but with heighth = 0 and stacked in one cell, so you can not use them anyway.
    Your a0dvice how to unhide rows before closing a workbook was very helpful, I have enterd the code into my worbooks and it works excelent, now I'd like to,distributethis sollution,among other ships our fleet. I was tinking about doing that by emails. with small,attachment,

    Best regards

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: this workbook code to unhide rows

    Hi,

    OK, I misunderstood.

    I had understood your initial request was to unhide VBA code which had been password protected by other users. The fact that you have protected it with your password makes all the difference.

    Let me have a think.

    Regards

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: this workbook code to unhide rows

    The answer would be to have an addin that contains the code. Then you can simply replace the addin with a newer version
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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