Using Mod function to trigger event

wpryan

Well-known Member
Joined
May 26, 2009
Messages
534
Office Version
  1. 365
Platform
  1. Windows
I am using a spreadsheet as a form which many persons may have to sign. The worksheet that would be used for signatures is locked, and must be unlocked when the signature cell is entered. Some signature cells are fixed in their location, others will be created by the form itself. The code for unlocking is:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim KeyCells As Range
    
    Set KeyCells = Union(Range("E13"), Range("E14"), Range("F20"))
        If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
            Sheets("Data").Unprotect Password:="Checklist"
        Else: Sheets("Data").Protect Password:="Checklist"
        End If
End Sub

What I need to figure out, is how to unlock the cells that will be created by the form. The cells will start in range F20, and be repeated every 4 rows (e.g. F24, F28, F32 etc.). I was thinking that maybe I can use the MOD function to identify the other cells to unlock. I'm not sure how to do it though. Any ideas on this, or other suggestions are welcome. Thanks in advance.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You could try this:
Code:
    If Target.Column = 6 And Target.Row >= 20 And Target.Row Mod 4 = 0 Then
        MsgBox Target.Address
    End If
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,467
Members
448,965
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top