Skip to main content

Conas cealla a ghlasáil nó a chosaint tar éis iontráil sonraí nó ionchuir isteach Excel?

Má tá bileog oibre agat agus nach gá ach sonraí áirithe a iontráil, agus tar éis duit sonraí a ionchur, ní mór duit na cealla a ghlasáil go huathoibríoch d’fhonn athruithe a chosc arís. Conas is féidir leat a dhéanamh chun é a bhaint amach? Is féidir leis an alt seo cabhrú leat.

Cealla a ghlasáil nó a chosaint tar éis sonraí a iontráil nó a ionchur le cód VBA


Cealla a ghlasáil nó a chosaint tar éis sonraí a iontráil nó a ionchur le cód VBA

Mar shampla, is é A1:F8 an raon áirithe cealla bána. Déan mar a leanas chun na cealla seo a ghlasáil tar éis iontráil sonraí Excel.

1. Díghlasáil an raon seo ar dtús, roghnaigh na cealla agus deaschliceáil, ansin roghnaigh Cealla Formáid sa roghchlár cliceáil ar dheis, agus sa Cealla Formáid bosca dialóige, gan an Faoi Ghlas bosca faoin cosaint cluaisín, agus ar deireadh cliceáil ar an OK cnaipe. Féach an pictiúr:

2. cliceáil Athbhreithniú > Bileog Cosanta. Agus sonraigh pasword chun an bhileog oibre seo a chosaint.

3. Cliceáil ar dheis ar an táb bileog, roghnaigh Féach an cód ón roghchlár cliceáil ar dheis. Ansin cóipeáil agus greamaigh an cód VBA thíos i bhfuinneog an Chóid. Féach an pictiúr:

Cód VBA: Glasáil nó cosaint cealla tar éis sonraí a iontráil nó a ionchur

Dim mRg As Range
Dim mStr As String

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Range("A1:F8"), Target) Is Nothing Then
    Set mRg = Target.Item(1)
    mStr = mRg.Value
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim xRg As Range
    On Error Resume Next
    Set xRg = Intersect(Range("A1:F8"), Target)
    If xRg Is Nothing Then Exit Sub
    Target.Worksheet.Unprotect Password:="123"
    If xRg.Value <> mStr Then xRg.Locked = True
    Target.Worksheet.Protect Password:="123" 
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range("A1:F8"), Target) Is Nothing Then
    Set mRg = Target.Item(1)
     mStr = mRg.Value
End If
End Sub

nótaí: Sa chód, is é “A1:F8” an raon a theastaíonn uait chun sonraí a ionchur; agus is é “123” an pasword den bhileog oibre chosanta seo. Athraigh iad de réir mar is gá duit.

4. Brúigh Eile + Q eochracha ag an am céanna chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

Tar éis dóibh sonraí a iontráil i gcealla raon A1: F8, cuirfear faoi ghlas iad go huathoibríoch. Agus gheobhaidh tú bosca dialóige pras má dhéanann tú iarracht aon ábhar cille den raon seo a athrú. Féach an pictiúr:


Earraí gaolmhara:

Uirlisí Táirgiúlachta Oifige is Fearr

Oifig Tacaíochta/Excel 2007-2021 agus 365 | Ar fáil i 44 Teanga | Éasca le Díshuiteáil go hiomlán

Gnéithe Coitianta: Aimsigh/Aibhsigh/Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha go Words, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Kutools for Excel Tá breis is 300 gné ann, A chinntiú nach bhfuil uait ach cliceáil ar shiúl...

Supercharge Do Excel scileanna: Éifeachtúlacht Taithí Mar Riamh Roimhe Le Kutools for Excel  (Triail Iomlán 30-Lá Saor in Aisce)

cluaisín kte 201905

Ráthaíocht Neamhchoinníollach Airgid Ar Ais 60-LáLeigh Nios mo... Íoslódáil saor in aisce ... Ceannach ... 

Office Tab Tugann sé comhéadan Tabbed chuig Oifig, agus Déan do chuid Oibre i bhfad níos éasca

  • Cumasaigh eagarthóireacht agus léamh tabáilte isteach Word, Excel, Pointe cumhachta, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méaduithe ar do tháirgiúlacht faoi 50%, agus laghdaítear na céadta cad a tharlaíonn nuair luiche duit gach lá! (Triail Iomlán 30-Lá Saor in Aisce)
Ráthaíocht Neamhchoinníollach Airgid Ar Ais 60-LáLeigh Nios mo... Íoslódáil saor in aisce ... Ceannach ... 
 
Comments (74)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
I want to lock a particular range after an entry and allow only one entry in that range.
the range already contains a data validation.
This comment was minimized by the moderator on the site
Hi Rakesh Chand,
Assuming the specific range is A1:D7, when you select an entry in any data validation of that range, the worksheet will be protected.
Please apply the following VBA code to get it done.

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20220831
    Dim xRg As Range
    Dim Rg As Range
    On Error Resume Next
    Set Rg = Range("A1:D7")
    Set xRg = Intersect(Rg, Target)
    If xRg Is Nothing Then Exit Sub
       
    Rg.Locked = True
    
        Rg.Worksheet.Protect Password:="123"
    
End Sub
This comment was minimized by the moderator on the site
доброго времени суток!
Возможно ли с помощью кода сделать следующие?
Есть таблица, к примеру 6 столбцов, в которую последовательно вносят данные в 5 столбов (присутствует режим "выбор из списка данных" и формулы), а в 6-ом выбирается фамилия вносившего. Возможно ли блокировать полностью строку с внесенными данными, только после заполнения последней ячейке в этой строке (6-ой столбец)?
Выше указанный способ блокирует ввод данных в ячейки где есть выбор из списка данных на всём листе.
Если есть такой вариант, буду очень признателен за код.
Заранее Спасибо!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Hi I am having an error with the deletion. Whenever I tried to click the delete the record a pop up will say "Microsoft Excel will permanently delete this sheet. Do you want to continue'.

Here's the code that I am using:

Sub Deletion()

Dim iRow As Long
Dim iSerial As Long


iSerial = Application.InputBox("Please enter Serial No. to delete the record.", "Delete", , , , , , 1)

On Error Resume Next

iRow = Application.WorksheetFunction.IfError _
(Application.WorksheetFunction.Match(iSerial, Sheets("Database").Range("A:A"), 0), 0)

On Error GoTo 0

If iRow = 0 Then

MsgBox "No record found.", vbOKOnly + vbCritical, "No Record"
Exit Sub

End If

Sheets("Database").Cells(iRow, 1).EntireRow.Delete Shift:=xlUp

End Sub


Please help me fix it. Thanks!
This comment was minimized by the moderator on the site
Hi guys. I need help and I'm new with VBA.
Say, I have Column BH with dropdown choices for Confirmed, Pending, and Cancelled.
All columns must remain unlocked for editing except for Columns A, BD, BE, and BF which must remain lock all the time.
If "Confirmed" is selected on Column BH, I want to lock the entire row before/next to it. Then, a password must be used if I want to edit the "Confirmed" row.
Can someone help me with this please?
Thanks in advance.

This comment was minimized by the moderator on the site
Good day...
Your tutorial is great!
I ran across a Run-Time error '13': during selection change if I select entire row. What is the turn-around for this? Any insight is much appreciated.
This comment was minimized by the moderator on the site
Hi,Which Excel version are you using?
This comment was minimized by the moderator on the site
Hi, This is all new to me. The formula is great. I want to lock cells D6:D36, H6:H35 & L6:L35 but can't get this to work. any help would be greatly appreciated.
This comment was minimized by the moderator on the site
Hi simon,If you want to lock cells in D6:D36, H6:H35 and L6:L35 separately after finish entering data in each range. Please do as follows.1. Select these three ranges by holding the Ctrl key;2. Do as the post described in step 1 to unlock these three ranges;3. Protect your worksheet with a password (Here my password is 123. This password will be used in the below code);4. Right click the sheet tab and then paste the below VBA code into the Code editor, and then press Alt + Q keys to close the Microsoft Visual Basic for Applications window.Notes: 1) In the code, you can change the ranges and password as you need;2)After pressing Alt + Q keys to close the code window, you need to shift to another worksheet and then go back to current sheet to make the code work. Otherwise, error will be occurred.<div data-tag="code">Dim mRg As Range
'Updated by Extendoffice 20201030
Dim mStr As String
Dim mStrAddress As String
Dim mArr
Private Sub Worksheet_Activate()
On Error Resume Next
Erase mArr()
mStrAddress = "D6:D36,H6:H35,L6:L35"
mArr = Split(mStrAddress, ",")
End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim xI As Integer
For xI = 0 To UBound(mArr)
If Not Intersect(Range(mArr(xI)), Target) Is Nothing Then
Set mRg = Target.Item(1)
mStr = mRg.Value
Exit For
End If
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
Dim xI As Integer
On Error Resume Next
For xI = 0 To UBound(mArr)
Set xRg = Null
Set xRg = Intersect(Range(mArr(xI)), Target)
If Not (xRg Is Nothing) Then
Target.Worksheet.Unprotect Password:="123"
If xRg.Value <> mStr Then xRg.Locked = True
Target.Worksheet.Protect Password:="123"

End If
Next
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xI As Integer
On Error Resume Next
For xI = 0 To UBound(mArr)
If Not Intersect(Range(mArr(xI)), Target) Is Nothing Then
Set mRg = Target.Item(1)
mStr = mRg.Value
End If
Next
End Sub
This comment was minimized by the moderator on the site
If Not Intersect(Range("CUSTOMER!"), Target) Is Nothing Then
I got an error. I want to protect the whole sheet
This comment was minimized by the moderator on the site
Good afternoon ... thank you again for this great resource. I do have one question. We have a shared document that is used by multiple users for input purposes. We have noticed that if User A enters data in a given cell, User A cannot edit per the code above (which is exactly what we want) but User B who the document is also shared with can delete the data that User A entered. Is there a revision for the code above that could be included in a shared document that has multiple users that are entering data.
This comment was minimized by the moderator on the site
Hi
I want to auto lock cell while i'm saving my worksheet
Can you help me how to do this in vba
This comment was minimized by the moderator on the site
Good morning,
I want to make it so that when a specific cell="Complete" the rest of that row locks. How would I modify this? Let's say that someone enters data into columns A through D and then Column E they enter "Complete" to lock A:E for that row.
Thank you,
Will
This comment was minimized by the moderator on the site
Hi Will,
Try this VBA. When entering "Complete" in any cell in column E, the rest cells of that row will be locked.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)



For Each cell In Range("E1:E500")

If cell.Value = "Complete" Then

ActiveSheet.Unprotect "Password"

cell.EntireRow.Locked = True

ActiveSheet.Protect "Password"

End If

Next cell



End Sub
This comment was minimized by the moderator on the site
Thank you so much for this, it is really helpful!
One of my colleagues is working on a notebook that isn't able to install Microsoft Excel but through Microsoft Teams she can access this workbook.Something we were wondering about for another sheet would be if the password were typed into cell AZ1 then all the other cells would unlock, but if the password is not currently in the cell the cells would switch back to locked. Is this feasible?
This comment was minimized by the moderator on the site
Thanks so much! I just got a chance to test this while setting up our logging sheet for next month and this works fantastic. One thing I did notice is that reading for "Complete" is case sensitive. Sometimes the logger will put in "complete" and the data limitation allows it. To include this, would I just copy that "If" to "End If" and put "complete"?
This comment was minimized by the moderator on the site
Hi,Can this be done in google sheet, if yes please let me know the procedure.
This comment was minimized by the moderator on the site
Hi John,
This can't be done in google sheet. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
HI,
Can this be done in Google sheet if yes how?
This comment was minimized by the moderator on the site
For those who want to protect different range of cells you can edit the range in the code like what I did. Use "comma" if making multiple cells.
This comment was minimized by the moderator on the site
hello if i have entered data from A1 right up to F and from A2 right up to F what will be the range that i have to input on the VBA code listed above in order to protect the cell A1,B1, C1, D1, E1, F1 AND A2, B2, C2, D2, E2, F2
This comment was minimized by the moderator on the site
Hi,

Please, can you help with my needs?

I am looking for VBA code - Once I save the sheet then can't edit on used cells and only allow to enter in new cells. Save by clicking save symbol or close file.

I tried various options but I unable to get them correctly, sometimes works and sometimes fail to work. Please help.
This comment was minimized by the moderator on the site
Hi
how do i increase range? I have already done protect sheet and i want to increase rage how do i do it>
This comment was minimized by the moderator on the site
I am looking same sort of thing but data range is in different cells eg, B3:D44 and then F20:H122 and so on 5 or 6 different ranges, could you please elaborate how to make VB code for it?
This comment was minimized by the moderator on the site
After implementing this code, I can no longer sign my signature in Excel's signature tool. What code can I add so that this won't occur? I can set it so that one can edit objects but as soon as I type something into one of my protected cells the options are reset and I can't use the signature box. Any help would be appreciated
This comment was minimized by the moderator on the site
Unlock the Worksheet, and when protecting again, enable the edit object checkbox before confirming passwords
This comment was minimized by the moderator on the site
Hi, something like this in google sheet?
This comment was minimized by the moderator on the site
Hi Jim,
Didn't text in google sheet. Thanks for your comment.
This comment was minimized by the moderator on the site
Hello there, how can I use this so that the user inputs the data in a range and then must click a submit button/cell to lock the cells?
This comment was minimized by the moderator on the site
Good day,
Can't help you solving this problem yet. Thanks for your comment.
This comment was minimized by the moderator on the site
If the cell is currently empty (but has previously been filled) is there a way to make it editable rather than protected?
This comment was minimized by the moderator on the site
it doesn't seem to work if i have some cells merged. is there a solution for that?
This comment was minimized by the moderator on the site
Hi,
If there are merged cells in the specified range, please try the following code.

Dim mRg As Range
Dim mStr As String

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Range("A1:F8"), Target) Is Nothing Then
Set mRg = Target.Item(1)
mStr = mRg.Value
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("A1:F8"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="123"
If xRg.Value <> mStr Then xRg.MergeArea.Locked = True
Target.Worksheet.Protect Password:="123"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range("A1:F8"), Target) Is Nothing Then
Set mRg = Target.Item(1)
mStr = mRg.Value
End If
End Sub
This comment was minimized by the moderator on the site
SIR I SUCCESS TO PROTECT AND LOCK CELL BUT I WANT TO EDIT CELLS WHEN THEY LOCKED ONLY THROUGH CELLS CLICK AND ASK PASSWORD TO EDIT CELL . HOW TO DO THIS ..?
This comment was minimized by the moderator on the site
Hi SURENDAR,
Sorry can't help with that. Thank you for your comment.
This comment was minimized by the moderator on the site
Sir, when pasting code after double click in selected entry cell which cell enter the data the cell did not permission to entry value please fix the problem modify the code.
This comment was minimized by the moderator on the site
Hi,
The code has been updated with the problem solving, please have a try. Thank you for your comment.
This comment was minimized by the moderator on the site
Hello, I'm trying to code so that a user can double-click and it will capture their username and timestamp. I was the cells to lock immediately after this is completed. I have the following in VBA, but it keeps debugging back to the "Target = Environ("USERNAME") & " " & Now()". I am VERY new and VERY inexperienced w/ VBA, so please bear with me if it's something small I'm doing wrong.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Target = Environ("USERNAME") & " " & Now()
Cancel = True

End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
On Error Resume Next
Set xRg = Intersect(Range("A1:D45"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="GENERAL"
xRg.Locked = True
Target.Worksheet.Protect Password:="GENERAL"
End Sub
This comment was minimized by the moderator on the site
Hi Jess,
The below VBA code can help you.
Note: When protecting the worksheet, please uncheck the "Select locked cells" option in the Protect sheet dialog box. Thank you for your comment.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim xRg As Range
On Error Resume Next
If ProtectContents Then
Set xRg = Intersect(Range("A1:D4"), Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="123"
Target = Environ("USERNAME") & " " & Now()
Target.Locked = True
Target.Worksheet.Protect Password:="123"
Cancel = True
End If
End Sub
This comment was minimized by the moderator on the site
when I get out of the currently working file and opened it again I found that new cell not locked after data entry, only the previous lock cell found lock. any solution
This comment was minimized by the moderator on the site
Hi Nazmul,
You need to save the workbook as an Excel Macro-Enabled Workbook before closing it.
This comment was minimized by the moderator on the site
Thanks man, This Saved my job : D
This comment was minimized by the moderator on the site
Hi - this post was very helpful and works perfectly. However, my filters stop working when the cells lock. Is there a way around this? Thanks!
This comment was minimized by the moderator on the site
Hi Kim,
Sorry can't help with this. The filter feature is disabled in a protected worksheet by default.
This comment was minimized by the moderator on the site
hello there need some help


im actually doing a working roster for a large group of people, and this sheet is accessible by all so that they can key in their requests for days off/ annual leaves etc. however i want to only limit a number of people on leave for each day (maximum 5 on leave) and after 5 leave requests are keyed in for the day, no body else can fill anymore requests for that particular date.


is there any code/function that will calculate the number of specific requests perday then when the quota is reached, then the other cells are blocked for the requests as to not exceed? thanks in advance
This comment was minimized by the moderator on the site
Good day,
Welcome to post any question in our forum: https://www.extendoffice.com/forum.html.
You will get more Excel supports from our professional or other Excel fans.
This comment was minimized by the moderator on the site
Good Morning,

Is there anyway to prevent a user from right clicking "view code" and seeing the admins password?
This comment was minimized by the moderator on the site
Never mind, I got it.
This comment was minimized by the moderator on the site
How? i didn't get it...
This comment was minimized by the moderator on the site
Hello,
Is there a way to lock only cells rather than the whole sheet? For example, if a user enters "Yes" in A2, then A2 would lock immediately as to not allow any changes. I would still like if others could still edit any other cell too. Thanks!
This comment was minimized by the moderator on the site
Hi Smith,
The below VBA code can help you solving the problem. Please have a try and thank you for your comment.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Target.Worksheet.Unprotect Password:="123"
Target.Locked = True
Target.Worksheet.Protect Password:="123"
End Sub
This comment was minimized by the moderator on the site
Hi
editing the code is there a way i can get it to lock all the cells in the range after data has been entered into one cell within that range ? so they can only enter data into one cell within the range not multiple.


thank you
This comment was minimized by the moderator on the site
Dear Jackie,
The below VBA code can help you solve the problem.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
Dim xSRg As Range
On Error Resume Next
Set xSRg = Range("A1:F8")
Set xRg = Intersect(xSRg, Target)
If xRg Is Nothing Then Exit Sub
Target.Worksheet.Unprotect Password:="123"
xSRg.Locked = True
Target.Worksheet.Protect Password:="123"
End Sub
This comment was minimized by the moderator on the site
Hi


i want it to lock the range after entry into one cell in the range please can you advise how i need to edit this to do this thank you
This comment was minimized by the moderator on the site
is it have to coding?
This comment was minimized by the moderator on the site
cells are not even editable...what went wrong don't understand pls help
This comment was minimized by the moderator on the site
Good Day,
At first, you need to set specified cells to Unlocked for editig, and then protect the worksheet. And finally apply the VBA script.
This comment was minimized by the moderator on the site
Hi,
Sir i want to lock after one time input data !
Like i am following one customer and write status , then any more employee cant edit or modify that !
This comment was minimized by the moderator on the site
Good Day,
Method in this post can also help you to solve this problem.
This comment was minimized by the moderator on the site
Thanx for the coding, but I've a problem to put 2 coding in 1 sheet, pls help.
This comment was minimized by the moderator on the site
Dear Fair,
Sorry can't solve this problem.
This comment was minimized by the moderator on the site
i like to lock only the edited cells. once i enter any data to the empty cells, i require to lock the edited cell to be automitically locked but not the empty cells.
This comment was minimized by the moderator on the site
Dear Subhash,
After using the code, only the edited cells are locked in the specified range. And you can still enter data into the empty cells in the specified range as you need. After fill in the blank cell, it will be locked automatically.
This comment was minimized by the moderator on the site
No, it locks the whole range at once after a data input into a cell in the range
This comment was minimized by the moderator on the site
Dear pradip,
Which Office version do you use?
This comment was minimized by the moderator on the site
For anyone who might have stumbled here since this comment. If you are having to unlock the worksheet EVERYTIME you fill in a cell then you need to first, - Unlock the spreadsheet - Highlight the area of the worksheet the code applies over - Right-click and go to 'format cells' - Go to the far right tab called 'Protection' and UNCHECK the 'Locked' section (Even if It appears as a solid fill instead of a tick) After that you will be able to enter data in multiple cells without having to unlock everytime. Bear in mind if you need to revisit locked cells to delete or edit information you may need to repeat the steps above. Hope this helps.
This comment was minimized by the moderator on the site
I tried the code and seemed to work somewhat. It does however allow me to delete the date entered into the cell but only stops me when I try to enter something else. Is there a way to keep data from being deleted?
This comment was minimized by the moderator on the site
Dear Stacy,
The same problem does not appear in my case. The code prevent users from entering as well as deleting data from the specified range. Would you provide your Office version for further testing?
This comment was minimized by the moderator on the site
Hello Sir , I am facing one problem with the same code while using this code with other cobe in VBA. Please suggest me some solution Thanks and Regards Gourav
This comment was minimized by the moderator on the site
Dear Gourav,
Sorry can't solve this problem.
This comment was minimized by the moderator on the site
Thanks for the code. Please let me know how to do auto lock the cells (similar to the ones listed by you) ONLY AFTER saving the file
This comment was minimized by the moderator on the site
Try this code instead: Private Sub Worksheet_Change(ByVal Target As Range) Dim MyRange As Range Set MyRange = Intersect(Range("A1:D100"), Target) If Not MyRange Is Nothing Then Sheets("Sheet1").Unprotect password:="hello" MyRange.Locked = True Sheets("Sheet1").Protect password:="hello" End If End Sub And remember to change range (A1:D100), password (hello) and sheet (Sheet1) names/numbers if it does not match the above :)
This comment was minimized by the moderator on the site
This is not working when it reopen excel file please help
This comment was minimized by the moderator on the site
Hello, I have a spreadsheet with the range A3:AN219, i would like to protect this range as and when input complete. Please help me on this. I tried above code but it is not working for me
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations