
Shawn Wallack
Member
Members

Forum Posts: 77
Member Since:
December 7, 2021
December 7, 2021

Hi -
I have a worksheet with a pivot table that starts in cell W1. It's important that the table does not move to a different column or row, because the specific cell address "W2" is referenced in multiple formulas. The table is located in hidden cells.
I need to prevent the user from inserting or deleting rows or columns through any mechanism. Here is what I have so far, but I think I must be missing something my more "creative" users may attempt.
Also, I can't seem to disable the "Clear Contents" option.
Any thoughts?
Sub AllowInsertDeleteRowCols(bSwitch As Boolean) Dim ctrl As CommandBarControl ' Row delete For Each ctrl In Application.CommandBars.FindControls(ID:=293) ctrl.Enabled = bSwitch Next ctrl ' Column delete For Each ctrl In Application.CommandBars.FindControls(ID:=294) ctrl.Enabled = bSwitch Next ctrl ' Row and column insert For Each ctrl In Application.CommandBars.FindControls(ID:=3183) ctrl.Enabled = bSwitch Next ctrl ' Cell delete For Each ctrl In Application.CommandBars.FindControls(ID:=292) ctrl.Enabled = bSwitch Next ctrl ' Cell insert For Each ctrl In Application.CommandBars.FindControls(ID:=3181) ctrl.Enabled = bSwitch Next ctrl ' Clear contents For Each ctrl In Application.CommandBars.FindControls(ID:=873) ctrl.Enabled = bSwitch Next ctrl If bSwitch Then Application.OnKey "{DELETE}" Else Application.OnKey "{DELETE}", "" End If End Sub Sub DisableActions Call AllowInsertDeleteRowCols(False) End Sub Sub EnableActions Call AllowInsertDeleteRowCols(True) End Sub
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Mynda Treacy, Alan Sidman, John DiMatteo
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
jaryszek: 183
Newest Members:
Trevor Pindling
Stevan Kanjo
Erin Sheldon
Nikita Bhatia
Sheilah Taylor
Clare Webber
David Jenssen
Dominic Brosnahan
Young You
Jennifer Owens
Forum Stats:
Groups: 3
Forums: 24
Topics: 6525
Posts: 28555
Member Stats:
Guest Posters: 49
Members: 32808
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —
