If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Locked grouped rows problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-05, 13:33
bhavesh78 bhavesh78 is offline
Registered User
 
Join Date: Dec 2004
Posts: 78
Question Locked grouped rows problem

Hi,

I have a sheet that is locked (by macro) and distributed to users. Some of the rows in the sheet are grouped together. The problem is that, if the sheet is locked, the user cannot expand/contract the grouped rows.

Is there a way using macro/VB code so that user can expand/contract the grouped rows while the sheet remains locked.

Thanks.

Bhavesh
Reply With Quote
  #2 (permalink)  
Old 01-05-05, 13:42
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
What version of XL are you using? With XL 2002 or 2003, you have more options to allow users to make changes.

Yes, you can code to unlock and relock. However, maybe a better way is to allow UserInterfaceOnly, and control all options within code (including the grouping options). This prevents changes by the user, but allows code to manipulate the worksheet.
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #3 (permalink)  
Old 01-05-05, 15:59
bhavesh78 bhavesh78 is offline
Registered User
 
Join Date: Dec 2004
Posts: 78
I am using XL2002 on Win2000 platform.
Can you please elaborate on the code part. What I need is-- to let user expand/contract rows on a locked worksheet.

Thank you.

Bhavesh.
Reply With Quote
  #4 (permalink)  
Old 01-05-05, 16:50
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
It may depend on how complicated you want the choices.

Code:
Sub ProtectAndAllowGrouping() 

   Dim strPassword As String 

   strPassword = "mypassword" 

   ActiveSheet.EnableOutlining = True 
   ActiveSheet.Protect Password:=strPassword, userinterfaceonly:=True 

End Sub
This protects the active sheet with password "mypassword" but still allows user to expand and contract groups. Problem: settings are not saved once you close and re-open the workbook.

Possible solution: call the macro automatically each time the workbook opens [code goes in Workbook code module]:

Code:
Private Sub Workbook_Open() 
   ProtectAndAllowGrouping 
End Sub
(To open the workbook code module double-click the ThisWorkbook icon in the VBE Project Explorer. Or, right-click the workbook's icon in Excel and choose View Code.)
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums

Last edited by shades; 01-05-05 at 16:55.
Reply With Quote
  #5 (permalink)  
Old 01-05-05, 18:36
bhavesh78 bhavesh78 is offline
Registered User
 
Join Date: Dec 2004
Posts: 78
Question

Cool. The code works great. Thanks Shades.

My other problem now is that I am unlocking only one row in the macro. This one row is replaced by multiple rows fetched from database and grouped together in one row when another macro is triggered.

Now since I have unlocked only one row, I am able to edit only the first row of the grouped rows. Is there a way to unlock all the rows that are grouped together. I cannot hard code the values in macro as the rows are fetched from database and the number of rows is unknown.

Thanks again for all your time and effort.

~BS

Last edited by bhavesh78; 01-05-05 at 19:23.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On