Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2006, 08:11 PM
Registered User
 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Protect cells and allow grouping/un-grouping

How do I build a macro that will not allow users to change the contents of the cells but allow them to group and un-group rows?

 
Old December 13th, 2006, 05:23 AM
Authorized User
 
Join Date: Mar 2006
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

first you need to protect the sheet.. then you have a number of options. a good one is to have a make a rightclick event to ungroup/group , something a bit like this

Code:
Sub RunThisFirst()
    Application.CommandBars("Cell").Reset
    With Application.CommandBars("Cell").Controls.Add
        .Caption = "Ungroup / Group"
        .OnAction = "GroupUngroup"
        .Tag = "GroupUngroup"
    End With

End Sub


Sub GroupUngroup()


    If Rows(ActiveCell.Row - 1).Hidden = True Then
       ExecuteExcel4Macro "SHOW.DETAIL(1," & ActiveCell.Row & ",TRUE)"
    Else
       ExecuteExcel4Macro "SHOW.DETAIL(1," & ActiveCell.Row & ",FALSE)"
    End If

End Sub
 
Old December 13th, 2006, 08:00 PM
Registered User
 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

jrogers,

I am still having trouble. Can I possibly send you the document?

Thanks for your help,
Scott

 
Old December 14th, 2006, 12:01 AM
Registered User
 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What does the Sub RunThisFirst do?

 
Old December 14th, 2006, 08:01 AM
Authorized User
 
Join Date: Mar 2006
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

run this macro first.. either as an on open. ths will creat an option when you right click that gives you an option to ungroup... you need to unprotect the sheet frist, then reprotect after






Similar Threads
Thread Thread Starter Forum Replies Last Post
Muenchian Grouping Chamkaur XSLT 1 June 21st, 2006 10:51 AM
does grouping sort too? wyatt.smith XSLT 4 March 17th, 2005 10:41 AM
grouping tools Cclhodges Beginning VB 6 2 June 2nd, 2004 10:30 AM
Grouping Nodes shoei78 XSLT 3 May 28th, 2004 10:34 PM
SQL Grouping kilika SQL Server 2000 10 May 26th, 2004 11:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.