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
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
Hi,
Use the Workbook_BeforeClose event and add the following instruction
adjust the rows 1:10 as necessary![]()
Private Sub Workbook_BeforeClose(Cancel As Boolean) Range("A1:A10").EntireRow.Hidden = True End Sub
Richard Buttrey
RIP - d. 06/10/2022
If any of the responses have helped then please consider rating them by clicking the small star iconbelow the post.
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.
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
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
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks