multiple force mandatory cell entry before continue

handri

Board Regular
Joined
Nov 25, 2017
Messages
88
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi,

I created a worksheet. Before others can use this worksheet for data entry. They must fill specific cell as below at first place. Than continue entering data. If not, they are not able to continue their work.

1. B3
2. D3
3. F3.

How do i can do this.

thank you
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi,

You can make the sheet protected via some code.

Right click on the sheet tab and click view code.
In the VBA Editor that appears, paste this code.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B3, D3, F3")) Is Nothing Or Target.Count > 1 Then Exit Sub
    
    If Range("B3").Value = "TheValueOfB3" And Range("D3").Value = "TheValueOfD3" And Range("F3").Value = "TheValueOfF3" Then
        Target.Worksheet.Unprotect Password:="YourPassWord"
    Else
        Target.Worksheet.Protect Password:="YourPassWord"
    End If
    
End Sub

Replace "TheValueOf" and "YourPassWord" with the value you want in the cell to unprotect.

You might also want to Unlock these 3 cells before pasting this macro.
Right click on the cell, go to cell format, and in the protectin tab, uncheck "Locked".

If it didn't help please tell me what are the conditions for the sheet to be editable.
 
Last edited:
Upvote 0
thanks louish, i dont need to protected this sheet with code. For the cell B3, D3 and F3. They must fill some number regarding jobs required. But the 1st thing is before they start to entering data this 3 cell B3, D3 and F3 must fill 1st.

thank you
Hi,

You can make the sheet protected via some code.

Right click on the sheet tab and click view code.
In the VBA Editor that appears, paste this code.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B3, D3, F3")) Is Nothing Or Target.Count > 1 Then Exit Sub
    
    If Range("B3").Value = "TheValueOfB3" And Range("D3").Value = "TheValueOfD3" And Range("F3").Value = "TheValueOfF3" Then
        Target.Worksheet.Unprotect Password:="YourPassWord"
    Else
        Target.Worksheet.Protect Password:="YourPassWord"
    End If
    
End Sub

Replace "TheValueOf" and "YourPassWord" with the value you want in the cell to unprotect.

You might also want to Unlock these 3 cells before pasting this macro.
Right click on the cell, go to cell format, and in the protectin tab, uncheck "Locked".

If it didn't help please tell me what are the conditions for the sheet to be editable.
 
Upvote 0
thanks louish, i dont need to protected this sheet with code. For the cell B3, D3 and F3. They must fill some number regarding jobs required. But the 1st thing is before they start to entering data this 3 cell B3, D3 and F3 must fill 1st.

thank you

Yes i understood that. But if you want to disable editing before these 3 cells are filled, you'll have to protect/unprotect the sheet.
So if the value they entered in the cell isn't important, use this :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B3, D3, F3")) Is Nothing Or Target.Count > 1 Then Exit Sub
    
    If Range("B3").Value <> "" And Range("D3").Value <> "" And Range("F3") <> "" Then
        Target.Worksheet.Unprotect Password:="YourPassWord"
    Else
        Target.Worksheet.Protect Password:="YourPassWord"
    End If
    
End Sub
 
Upvote 0
Yes i understood that. But if you want to disable editing before these 3 cells are filled, you'll have to protect/unprotect the sheet.
So if the value they entered in the cell isn't important, use this :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B3, D3, F3")) Is Nothing Or Target.Count > 1 Then Exit Sub
    
    If Range("B3").Value <> "" And Range("D3").Value <> "" And Range("F3") <> "" Then
        Target.Worksheet.Unprotect Password:="YourPassWord"
    Else
        Target.Worksheet.Protect Password:="YourPassWord"
    End If
    
End Sub

hi louish

In my vba. There is sheet1 and ThisWorkbook. Which one and how do i save as type file.

thanks
 
Upvote 0
hi louish

In my vba. There is sheet1 and ThisWorkbook. Which one and how do i save as type file.

thanks

Paste it in your sheet module (Sheet1). If you want to save the file you have to save it as .xlsm (macro-enabled).
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,993
Members
448,539
Latest member
alex78

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