+ Reply to Thread
Results 1 to 4 of 4

Locking & Protecting Cells Affected by Macro

  1. #1
    Registered User
    Join Date
    09-17-2008
    Location
    Canada
    Posts
    2

    Locking & Protecting Cells Affected by Macro

    I have a question regarding locking.



    I have the code setup as below. How ever I’m having a problem locking the cells columns L, M, N & protecting the sheet. If a user selects from the drop down list in Column J, then L/M/N will not populate and gives a debug error. Do you know how to fix this??





    Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Column = 10 Then

    Select Case Target.Value



    Case "Aberdeen"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case "Joffre"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case "Kegworth"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case "Lyalta"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case "Peace"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case "Rathwell"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case "Tisdale"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case "Virden"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case "Wilkie"

    Target.Offset(0, 2).Value = "Louis Dreyfus"

    Case Else

    Target.Offset(0, 2).Value = ""

    End Select

    End If



    If Target.Column = 10 Then

    Select Case Target.Value



    Case "Aberdeen"

    Target.Offset(0, 3).Value = "PO Box 303"

    Case "Joffre"

    Target.Offset(0, 3).Value = "Box 9 Site 2 RR2"

    Case "Kegworth"

    Target.Offset(0, 3).Value = "PO Box 101"

    Case "Lyalta"

    Target.Offset(0, 3).Value = "GD"

    Case "Peace"

    Target.Offset(0, 3).Value = "PO Box 544"

    Case "Rathwell"

    Target.Offset(0, 3).Value = "PO Box 129"

    Case "Tisdale"

    Target.Offset(0, 3).Value = "PO Box 656"

    Case "Virden"

    Target.Offset(0, 3).Value = "PO Box 2459"

    Case "Wilkie"

    Target.Offset(0, 3).Value = "PO Box 689"

    Case Else

    Target.Offset(0, 3).Value = ""

    End Select

    End If





    If Target.Column = 10 Then

    Select Case Target.Value



    Case "Aberdeen"

    Target.Offset(0, 4).Value = "S0K 0A0"

    Case "Joffre"

    Target.Offset(0, 4).Value = "T4L 2N2"

    Case "Kegworth"

    Target.Offset(0, 4).Value = "S0G 1Y0"

    Case "Lyalta"

    Target.Offset(0, 4).Value = "T0J 1Y0"

    Case "Peace"

    Target.Offset(0, 4).Value = "T0H 3A0"

    Case "Rathwell"

    Target.Offset(0, 4).Value = "R0G 1S0"

    Case "Tisdale"

    Target.Offset(0, 4).Value = "S0E 1T0"

    Case "Virden"

    Target.Offset(0, 4).Value = "R0M 2C0"

    Case "Wilkie"

    Target.Offset(0, 4).Value = "S0K 4W0"

    Case Else

    Target.Offset(0, 4).Value = ""

    End Select

    End If

    End Sub

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Welcome to the Forum. Please read the Forum Rules & use the Edit button to add Code Tags
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-17-2008
    Location
    Canada
    Posts
    2

    Locking & Protecting Cells Affected by Macro

    I have a question regarding locking.



    I have the code setup as below. How ever I’m having a problem locking the cells columns L, M, N & protecting the sheet. If a user selects from the drop down list in Column J, then L/M/N will not populate and gives a debug error. Do you know how to fix this??





    Please Login or Register  to view this content.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Amend your code
    Please Login or Register  to view this content.

+ 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. Macro to address cells in the next column to selection
    By miles_muso in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-16-2008, 07:34 AM
  2. Modify macro to count colored cells
    By headbanger51 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-15-2008, 05:51 PM
  3. Locking cells problem
    By punter in forum Excel General
    Replies: 4
    Last Post: 01-29-2007, 01:10 PM
  4. Locking non blank cells in range
    By chris100 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-13-2007, 08:22 PM
  5. Macro to hide columns based on contents of two cells
    By Korae13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2006, 12:40 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