Results 1 to 5 of 5

Add Message Box / Condition before Locking

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-14-2020
    Location
    Pakistan
    MS-Off Ver
    15
    Posts
    123

    Add Message Box / Condition before Locking

    hi gurus,

    I'm using the below code in my spreadsheet and it's working absolutely fine. The only thing I would like to add is a message box/condition.

    So in the code below - (I have bold it) - before that action I'd like the message box to say "are you sure you want to proceed" and If yes than continue, if no then don't do nothing. Also, even if yes but if there is no value in U4:U28 then don't continue the action

    Many thanks,



    Private Sub Worksheet_Change(ByVal Target As Range)
     
    If Target.CountLarge > 1 Then Exit Sub
     
    If Intersect(Target, Range("U4:U28, W4:W28, I4:Q4, E5:Q5, E6:Q6, E7:Q7, E8:Q8, E9:Q9, E10:Q10, E11:Q11, E12:Q12, E13:Q13, E14:Q14, E17:Q17, E18:Q18, E19:Q19, E20:Q20, E21:Q21, E22:Q22, E23:Q23, E24:Q24, E25:Q25, E26:Q26, E27:Q27, E28:Q28")) Is Nothing Then Exit Sub
     
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    ActiveSheet.Unprotect Password:="ab"
     
    If Not Intersect(Target, Range("U4:U28,W4:W28")) Is Nothing Then Target.Offset(0, 1).Value = Environ("username") & ", " & Format(Now, "dd/mm_hh.mm")
    
    Dim Rg As Range
        
        If ((Target.Column = 21) And (Target.Row >= 4)) Then
            If (Target.Value <> "") Then
                For Each Rg In Range(Cells(Target.Row, "E"), Cells(Target.Row, "Q"))
                    If (Rg = "") Then Rg = 0
                Next Rg
                End If
        End If
     
    
        If ((Target.Column = 23) And (Target.Row >= 4)) Then
            If (Target.Value <> "") Then
                Range(Cells(Target.Row, "C"), Cells(Target.Row, "W")).Locked = True
               ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
            End If
        End If
    
    
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    
    ActiveSheet.Protect Password:="ab"
    
    End Sub
    Last edited by samarbac; 01-17-2020 at 07:00 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 05-30-2018, 12:17 PM
  2. Adding an input message to each cell to bring back corrsponding message
    By Nic31 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-01-2014, 09:28 AM
  3. [SOLVED] How to pop up a warning message before any Excel automatic update link reminder message
    By billj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2013, 10:41 AM
  4. Extracting mail message(outlook) table in the message body
    By andywsw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2012, 10:14 PM
  5. need of pop up message dynamically using data validation input message method
    By vba_life in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2010, 09:03 AM
  6. [SOLVED] Intercept/replace standard 'cell protected' message with my own message?
    By KR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2006, 10:35 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