Results 1 to 3 of 3

How to allow users to add/delete rows/cloumns in sheets with macros.

Threaded View

damienchew How to allow users to... 03-11-2014, 08:25 PM
jewelsharma Re: How to allow users to... 03-11-2014, 11:55 PM
damienchew Re: How to allow users to... 03-13-2014, 12:08 AM
  1. #1
    Registered User
    Join Date
    01-05-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    13

    How to allow users to add/delete rows/cloumns in sheets with macros.

    Hi excel gurus,

    I have a sheet with macros that allows users to fill in data from columns F10 to O10 from row 10 to 54.
    Column P will then make some computations based on the inputs from col F to O.
    Row 55 will also make some computation based on inputs from row 10 to 54.
    How to I modify the code below to allow users to either add/delete columns and rows such that it does not fowl up the computations?
    The computation does not have to be at column P or at row 55, they can be dynamic and change depending on how many rows and columns the users delete/add.

    A little background on what the code does. From Column F to O, the code UNLOCKS the columns only if user inputs date in Cell 3 of that particular column.
    Example. Column F is locked from F10 to infinity at the start. Only when user inputs date into F3 does the cells F10:F54 is unlocked for user to input data.
    This goes on until column O. I want users to be able to add more columns, or delete ones they don't need.

    I hope I'm clear...

    Thanks Thanks.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim c As Range
    Application.EnableEvents = False
    For Each c In Target
        If Not IsError(c) And Not Intersect(c, Range("F3:O3")) Is Nothing Then
            If c.Value = "" Then
                Sheets(ThisWorkbook.ActiveSheet.Name).Unprotect Password:="1234" 'change to your actual password
                Range(Cells(10, c.Column), Cells(54, c.Column)).ClearContents
                Range(Cells(10, c.Column), Cells(54, c.Column)).Locked = True
                Sheets(ThisWorkbook.ActiveSheet.Name).Protect Password:="1234"
            Else
                Sheets(ThisWorkbook.ActiveSheet.Name).Unprotect Password:="1234" 'change to your actual password
                Range(Cells(10, c.Column), Cells(54, c.Column)).Locked = False
                Sheets(ThisWorkbook.ActiveSheet.Name).Protect Password:="1234"
            End If
        End If
    Next c
    Application.EnableEvents = True
    End Sub
    Last edited by damienchew; 03-13-2014 at 12:13 AM. Reason: Redefine Problem

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Multiplying rows and cloumns
    By skochar in forum Excel General
    Replies: 8
    Last Post: 11-21-2006, 06:51 AM
  2. [SOLVED] In a protected worksheet allow users to delete rows
    By Jason Trivett in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  3. In a protected worksheet allow users to delete rows
    By Ian in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  4. In a protected worksheet allow users to delete rows
    By Jason Trivett in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  5. In a protected worksheet allow users to delete rows
    By Jason Trivett in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-12-2005, 05:05 AM

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