+ Reply to Thread
Results 1 to 1 of 1

How to disable insert/delete columns & rows?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    How to disable insert/delete columns & rows?

    Hi,

    How do you hide the menu items related to inserting and deleting rows and columns?

    I have the following macro, but it only works about half the time and I don't know why. When it doesn't, I get the error:

    "Run time error 5: Invalid procedure or call argument" in both xl2003 and 2010.

    Sub HideMenuItems()
    
        With Application.CommandBars("Row")
            .Controls("Insert").Enabled = False
            .Controls("Delete").Enabled = False
        End With
    
        With Application.CommandBars("Column")
            .Controls("Insert").Enabled = False
            .Controls("Delete").Enabled = False
        End With
    
        With CommandBars("Worksheet Menu Bar")
            .Controls("Insert").Controls("Rows").Enabled = False
            .Controls("Insert").Controls("Columns").Enabled = False
            .Controls("Insert").Controls("Cells").Enabled = False
            .Controls("Edit").Controls("Delete").Enabled = False
        End With
    
    End Sub
    Thanks,

    Lawrence
    Last edited by skysurfer; 11-12-2010 at 10:38 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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