+ Reply to Thread
Results 1 to 2 of 2

Lock cells / ranges to an existing VBA code to create editable areas and allow VBA to run

  1. #1
    Registered User
    Join Date
    06-22-2022
    Location
    AUSTRALIA
    MS-Off Ver
    365 eXCEL
    Posts
    1

    Lock cells / ranges to an existing VBA code to create editable areas and allow VBA to run

    I haven't used VBA before so I'm really new to this :-) The below is the code I am currently using , and simply need to lock all area's of the sheet (with out using the sheet name) apart from A13:A377, B1, D3:D4, D13:D377, F13:I377. I can't protect the sheet because the VBA won't work. Help please...

    Private Sub Worksheet_Change(ByVal Target As Range)
    ' To allow multiple selections in a Drop Down List in Excel (without repetition)
    Dim Oldvalue As String
    Dim Newvalue As String
    Application.EnableEvents = True
    On Error GoTo Exitsub
    If Target.Column = 1 Then
    If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
    Else: If Target.Value = "" Then GoTo Exitsub Else
    Application.EnableEvents = False
    Newvalue = Target.Value
    Application.Undo
    Oldvalue = Target.Value
    If Oldvalue = "" Then
    Target.Value = Newvalue
    Else
    If InStr(1, Oldvalue, Newvalue) = 0 Then
    Target.Value = Oldvalue & " & " & Newvalue
    Else:
    Target.Value = Oldvalue
    End If
    End If
    End If
    End If
    Application.EnableEvents = True
    Exitsub:
    Application.EnableEvents = True
    End Sub

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    1,334

    Re: Lock cells / ranges to an existing VBA code to create editable areas and allow VBA to

    Try it:
    1. In worksheet module (full code):
    Please Login or Register  to view this content.
    2. In ThisWorkbook module:
    Please Login or Register  to view this content.
    3. Save and reopen this workbook.

    Artik

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Create editable query from cells
    By Undo in forum Excel General
    Replies: 0
    Last Post: 10-12-2021, 07:26 AM
  2. Lock and hidden cells and editable access
    By Musabi78 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-22-2020, 06:40 PM
  3. Replies: 10
    Last Post: 12-10-2018, 05:38 AM
  4. Adding lock cells to existing code
    By jgarnett in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2014, 08:46 AM
  5. [SOLVED] Editable areas
    By batya in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-09-2014, 12:33 AM
  6. Replies: 3
    Last Post: 06-30-2010, 09:46 AM
  7. using VB code to unlock and lock different areas on multiple sheets
    By Healthwatch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2010, 11:12 PM

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