Consulting

Results 1 to 3 of 3

Thread: How do I lock the contents of a moving cell?

  1. #1
    VBAX Newbie
    Joined
    Jul 2016
    Posts
    2
    Location

    How do I lock the contents of a moving cell?

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("m97").Value <> 0 Then
        Me.Tab.ColorIndex = 3
    Else
        Me.Tab.ColorIndex = xlColorIndexNone
    End If
    End Sub
    Ecel 16 - Windows 10 - PC

    I am using the above code to change he colour of the tab if money is still to be paid on a project. However, the user needs, on occasion, to insert rows above the designated cell "m97". Is there a way for me to lock the contents wherever they end up? Much as Excel does when you insert rows above a "sum" formula. If you can help I appreciate your time. MikeM

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Private Sub Worksheet_Change(ByVal Target As Range)
       Me.Tab.ColorIndex = 3*abs(cells(rows.count,13).end(xlup)<>"")
    End Sub

  3. #3
    VBAX Newbie
    Joined
    Jul 2016
    Posts
    2
    Location
    Sorry mark007 I should have headed the question with "Complete Muppet". I really don't understand your answer. Where do I insert the code and do I need the original reference cell? Sorry again this must be pretty boring for you guys. Thanks MikeM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •