मुख्य सामग्री पर जाएं

Excel में दिनांक के आधार पर सेलों की सुरक्षा कैसे करें?

लेखक: ज़ियाओयांग अंतिम संशोधित: 2020-07-24

आम तौर पर, हम दूसरों को सेल मानों को संपादित करने या संशोधित करने से रोकने के लिए वर्कशीट की सुरक्षा कर सकते हैं, लेकिन, कभी-कभी, आपको तारीख के आधार पर सेल की सुरक्षा करने की आवश्यकता होती है। उदाहरण के लिए, मैं अन्य कोशिकाओं की सुरक्षा करना चाहता हूं लेकिन केवल आज की तारीख के सेल मूल्यों को संशोधित करने की अनुमति देता हूं जैसा कि निम्नलिखित स्क्रीनशॉट में दिखाया गया है, यह लेख तारीख के आधार पर कोशिकाओं की सुरक्षा कैसे करें के बारे में बात करेगा।

दस्तावेज़ दिनांक 1 तक सुरक्षित रखें

आज की दिनांक पंक्ति को छोड़कर सभी पंक्तियों को VBA कोड से सुरक्षित रखें

दिनांक बीत चुकी सभी पंक्तियों को VBA कोड से सुरक्षित रखें


तीर नीला दायां बुलबुला आज की दिनांक पंक्ति को छोड़कर सभी पंक्तियों को VBA कोड से सुरक्षित रखें

केवल उस पंक्ति को संशोधित करने की अनुमति दें जो आज की तारीख के बराबर है, निम्नलिखित कोड आपकी मदद कर सकता है, कृपया ऐसा करें:

1. उस शीट टैब पर राइट क्लिक करें जिसे आप दिनांक के आधार पर कोशिकाओं की सुरक्षा करना चाहते हैं, और फिर चुनें कोड देखें संदर्भ मेनू से, पॉप आउट में अनुप्रयोगों के लिए माइक्रोसॉफ्ट विज़ुअल बेसिक विंडो, कृपया निम्नलिखित कोड को कॉपी करें और रिक्त मॉड्यूल में पेस्ट करें:

VBA कोड: आज की दिनांक पंक्ति को छोड़कर सभी पंक्तियों को सुरक्षित रखें:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice 20161025
    If Range("E" & Selection.Row).Value <> Date Then
        ActiveSheet.Protect Password:="111111"
        MsgBox "Only today's date row can be edited!", vbInformation, "Kutools for Excel"
    ElseIf Range("E" & Selection.Row).Value = Date Then
        ActiveSheet.Unprotect Password:="111111"
        ActiveSheet.EnableSelection = xlNoRestrictions
    End If
End Sub

दस्तावेज़ दिनांक 2 तक सुरक्षित रखें

नोट: उपरोक्त कोड में, अक्षर E वह कॉलम हेडर है जहां दिनांक स्थित है, "111111"इस शीट की सुरक्षा के लिए पासवर्ड है। आप इन्हें अपनी आवश्यकता के अनुसार बदल सकते हैं।

2. फिर इस कोड विंडो को सेव करें और बंद कर दें।

(1.) यदि आप आज की दिनांक पंक्ति के अलावा अन्य सेल पर क्लिक करते हैं, तो एक प्रॉम्प्ट बॉक्स आपको यह याद दिलाने के लिए पॉप अप होगा कि सेल को संपादित नहीं किया जा सकता है, स्क्रीनशॉट देखें:

दस्तावेज़ दिनांक 3 तक सुरक्षित रखें

(2.) यदि आप आज की तारीख के बराबर पंक्ति पर क्लिक करते हैं और संपादित करते हैं, तो इसे सफलतापूर्वक संशोधित किया जाएगा, स्क्रीनशॉट देखें:

दस्तावेज़ दिनांक 4 तक सुरक्षित रखें


तीर नीला दायां बुलबुला दिनांक बीत चुकी सभी पंक्तियों को VBA कोड से सुरक्षित रखें

यदि आपको बीत चुकी तिथि की सभी पंक्तियों को सुरक्षित रखने की आवश्यकता है, तो केवल आज और भविष्य की तिथि पंक्तियों को संशोधित करने की अनुमति दें, कृपया निम्नलिखित VBA कोड लागू करें:

1. उस शीट टैब पर राइट क्लिक करें जिसे आप दिनांक के आधार पर कोशिकाओं की सुरक्षा करना चाहते हैं, और फिर चुनें कोड देखें संदर्भ मेनू से, पॉप आउट में अनुप्रयोगों के लिए माइक्रोसॉफ्ट विज़ुअल बेसिक विंडो, कृपया निम्नलिखित कोड को कॉपी करें और रिक्त मॉड्यूल में पेस्ट करें:

वीबीए कोड: सभी पंक्तियों को सुरक्षित रखें तिथि बीत चुकी है:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Updateby Extendoffice 20161025
  Dim xRow As Long
  xRow = 2
  ThisWorkbook.ActiveSheet.Unprotect Password:="111111"
  ThisWorkbook.ActiveSheet.Cells.Locked = False
  Do Until IsEmpty(Cells(xRow, 5))
    If Cells(xRow, 5) < Date Then
      Rows(xRow).Locked = True
    End If
    xRow = xRow + 1
  Loop
  ThisWorkbook.ActiveSheet.Protect Password:="111111"
End Sub

दस्तावेज़ दिनांक 5 तक सुरक्षित रखें

नोट: उपरोक्त कोड में, संख्या 5 वह कॉलम संख्या है जहां दिनांक स्थित है, "111111"इस शीट की सुरक्षा के लिए पासवर्ड है। आप इन्हें अपनी आवश्यकता के अनुसार बदल सकते हैं।

3. फिर इस कोड विंडो को सेव करें और बंद कर दें।

(1.) यदि आप सेल की तारीख बीत चुकी है पर क्लिक करते हैं, तो एक प्रॉम्प्ट बॉक्स आपको याद दिलाने के लिए पॉप अप होगा कि सेल को संपादित नहीं किया जा सकता है, स्क्रीनशॉट देखें:

दस्तावेज़ दिनांक 6 तक सुरक्षित रखें

(2.) यदि आप आज की तारीख या भविष्य की तारीख में मान बदलने का प्रयास करने के लिए पंक्तियों के सेल पर क्लिक करते हैं, तो इसे सफलतापूर्वक संशोधित किया जाएगा, स्क्रीनशॉट देखें:

दस्तावेज़ दिनांक 7 तक सुरक्षित रखें

सर्वोत्तम कार्यालय उत्पादकता उपकरण

🤖 कुटूल्स एआई सहयोगी: निम्न के आधार पर डेटा विश्लेषण में क्रांति लाएं: बुद्धिमान निष्पादन   |  कोड जनरेट करें  |  कस्टम फ़ॉर्मूले बनाएं  |  डेटा का विश्लेषण करें और चार्ट बनाएं  |  कुटूल फ़ंक्शंस का आह्वान करें...
लोकप्रिय सुविधाएँ: डुप्लिकेट ढूंढें, हाइलाइट करें या पहचानें   |  रिक्त पंक्तियाँ हटाएँ   |  डेटा खोए बिना कॉलम या सेल को संयोजित करें   |   फॉर्मूला के बिना गोल ...
सुपर लुकअप: एकाधिक मानदंड VLookup    मल्टीपल वैल्यू वीलुकअप  |   अनेक शीटों में VLookup   |   फजी लुकअप ....
उन्नत ड्रॉप-डाउन सूची: शीघ्रता से ड्रॉप डाउन सूची बनाएं   |  आश्रित ड्रॉप डाउन सूची   |  बहु-चयन ड्रॉप डाउन सूची ....
स्तम्भ प्रबंधक: कॉलमों की एक विशिष्ट संख्या जोड़ें  |  कॉलम ले जाएँ  |  छिपे हुए कॉलम की दृश्यता स्थिति टॉगल करें  |  रेंज और कॉलम की तुलना करें ...
फीचर्ड फीचर्स: ग्रिड फोकस   |  डिजाइन देखें   |   बड़ा फॉर्मूला बार    कार्यपुस्तिका एवं शीट प्रबंधक   |  संसाधन लाइब्रेरी (ऑटो टेक्स्ट)   |  खजूर बीनने वाला   |  कार्यपत्रकों को संयोजित करें   |  एन्क्रिप्ट/डिक्रिप्ट सेल    सूची के अनुसार ईमेल भेजें   |  सुपर फ़िल्टर   |   विशेष फ़िल्टर (फ़िल्टर बोल्ड/इटैलिक/स्ट्राइकथ्रू...) ...
शीर्ष 15 टूलसेट12 टेक्स्ट टूल्स (पाठ जोड़ें, अक्षर हटाएँ, ...)   |   50 + चार्ट प्रकार (गैन्ट चार्ट, ...)   |   40+ प्रैक्टिकल सूत्र (जन्मदिन के आधार पर आयु की गणना करें, ...)   |   19 निवेशन टूल्स (QR कोड डालें, पथ से चित्र सम्मिलित करें, ...)   |   12 रूपांतरण टूल्स (शब्दों को संख्याएँ, मुद्रा रूपांतरण, ...)   |   7 विलय और विभाजन टूल्स (उन्नत संयोजन पंक्तियाँ, विभाजन कोशिकाओं, ...)   |   ... और अधिक

एक्सेल के लिए कुटूल के साथ अपने एक्सेल कौशल को सुपरचार्ज करें, और पहले जैसी दक्षता का अनुभव करें। एक्सेल के लिए कुटूल उत्पादकता बढ़ाने और समय बचाने के लिए 300 से अधिक उन्नत सुविधाएँ प्रदान करता है।  वह सुविधा प्राप्त करने के लिए यहां क्लिक करें जिसकी आपको सबसे अधिक आवश्यकता है...

Description


ऑफिस टैब ऑफिस में टैब्ड इंटरफ़ेस लाता है, और आपके काम को बहुत आसान बनाता है

  • Word, Excel, PowerPoint में टैब्ड संपादन और रीडिंग सक्षम करें, प्रकाशक, एक्सेस, विसियो और प्रोजेक्ट।
  • नई विंडो के बजाय एक ही विंडो के नए टैब में एकाधिक दस्तावेज़ खोलें और बनाएं।
  • आपकी उत्पादकता 50% बढ़ जाती है, और आपके लिए हर दिन सैकड़ों माउस क्लिक कम हो जाते हैं!
Comments (31)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
i want to automatically move data (file A) on a column or a row to another file(file B), but when B file is in closed state, code can't work. how can i do it without open B file
please help me
This comment was minimized by the moderator on the site
Hello, I would like to protect future days and allow editing current and past days. How do I do that?
This comment was minimized by the moderator on the site
Hello, Miguel,To protect the future days, please apply the below code:<div data-tag="code">Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Updateby Extendoffice
Dim xRow As Long
xRow = 2
ThisWorkbook.ActiveSheet.Unprotect Password:="111111"
ThisWorkbook.ActiveSheet.Cells.Locked = False
Do Until IsEmpty(Cells(xRow, 5))
If Cells(xRow, 5) > Date Then
Rows(xRow).Locked = True
End If
xRow = xRow + 1
Loop
ThisWorkbook.ActiveSheet.Protect Password:="111111"
End SubPlease try, hope it can help you!
This comment was minimized by the moderator on the site
hello i did it but when i press cell message shows that it can not be edited but when i press keyborad i still can write in the cell
This comment was minimized by the moderator on the site
Hello, I tried to do the same but to Protect all columns except today’s date column with VBA code by replacing "Selection.Row" with "Selection.Columns" and "E" with "5" (row number where dates are), but I keep receiving error 1004!

Any help please?

Thank you
This comment was minimized by the moderator on the site
Hello,
To apply this code to columns that you need, please use the following VBA code:(Note: In the code, 5 is the row number contains the date, please change it to your need.)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xRg As Range
Set xRg = Target.Worksheet.Cells(5, Target.Column)
If xRg <> Date Then
ActiveSheet.Protect Password:="111111"
MsgBox "Only today's date row can be edited!", vbInformation, "Kutools for Excel"
ElseIf xRg.Value = Date Then
ActiveSheet.Unprotect Password:="111111"
ActiveSheet.EnableSelection = xlNoRestrictions
End If
End Sub

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Hi Im facing one problem, once i close the file and reopens it again on the same date, code doesnot work. pls help im stuck
This comment was minimized by the moderator on the site
Hi, rohit,
To keep the code, you should save your workbook as Excel Macro-Enabled Workbook format, please try, thank you!
This comment was minimized by the moderator on the site
Thanks for your help, Thanku so much buddy, It is a great help. and solved my tension.
Be safe
RegardsRohit Khanna
This comment was minimized by the moderator on the site
Thank you! Sorry, I did not get your reply until now, it might be a problem in my email.

It worked! Can't say thank you enough! I really appreciate that!
This comment was minimized by the moderator on the site
Hi,
Glad it can help you!
This comment was minimized by the moderator on the site
Hi,

I am trying to expand this to protect columns that do not include this current month or/and this current week. I tried to replace "Date" with "month" or "week", but did not work.

I have attached a sample for weeks sheet where user cannot edit or type in columns other than this week.

Any advice on that? or shall I use actual dates to reflect a day in the month?
This comment was minimized by the moderator on the site
Hello, I tried to do the same but to Protect all columns except today’s date column with VBA code by replacing "Selection.Row" with "Selection.Columns" and "E" with "5" (row number where dates are), but I keep receiving error 1004!

Any help please?

Thank you
This comment was minimized by the moderator on the site
Hi,

while running this code I am getting an error as shown in the figure
Also i am attaching a snapshot my excel where i want to make changes..

Can u guide in my code where should i make changes according to my excel file so that cells that contain only todays & future date can be editied ???
This comment was minimized by the moderator on the site
Hello, Karan,
Because there are merged cells in your table, the above code can not be applied correctly in merged cells table.
If you have any other good ideas, please comment here. Thank you!
This comment was minimized by the moderator on the site
As someone who is relatively new to VBA, would you mind explaining why xRow = 2 in Line 4?



Thanks
This comment was minimized by the moderator on the site
because in row no. 1 you have header
This comment was minimized by the moderator on the site
This works great. but how can I switch it to unlock a column based on dates in row 3?
This comment was minimized by the moderator on the site
Hello.....


I am using the code for Protect all rows except today’s date row........



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice 20161025
If Range("A" & Selection.Row).Value <> Date Then
ActiveSheet.Protect Password:="111111"
MsgBox "Only today's date row can be edited!", vbInformation, "Kutools for Excel"
ElseIf Range("E" & Selection.Row).Value = Date Then
ActiveSheet.Unprotect Password:="111111"
ActiveSheet.EnableSelection = xlNoRestrictions
End If
End Sub


After i save i and click on cell i get message only today's date row can be edited....but if i double click the cell the i can edit...pls help
This comment was minimized by the moderator on the site
hi is it possible to lock certain cells depending on the date that is directly above them in a column?
This comment was minimized by the moderator on the site
Hi, Lusis,
Can you give your problem more specifically? Or you can attach a screenshot as your problem.
Thank you!
This comment was minimized by the moderator on the site
Hi skyyang

Yes here is a screenshot. Hope this helps.
This comment was minimized by the moderator on the site
Here it is.
This comment was minimized by the moderator on the site
Hello, Lucis,
Do you mean to lock the columns which date is past, and only the columns of today and future days can be modified?
This comment was minimized by the moderator on the site
Correct! How would I go about that?
This comment was minimized by the moderator on the site
Hi, Luis,
How about the date cell in A1? Is it entered manually or entered with a formula =now()? If it is a formula cell, the locked columns will be changed with the date changes.
Looking forward to your reply!
This comment was minimized by the moderator on the site
Hi Skyyangg

yes the cell A1 has the =now() formula.

thanks!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations