VBA Code Not Unlocking Cell
Jun 7, 2014
I have this code:
Code:
Private Sub WorkSheet_Activate()
'Open workbook and default all main page dynamic data
Application.EnableEvents = False
With Worksheets("MAIN")
.Unprotect
.Range("F3").Value = ""
.Range("O5,T5, F6") = ""
[code]....
It is triggered when protected worksheet "MAIN" is activated. EnableEvents=False prevents any worksheet change triggers as cells are defaulted. Ranges F3. O5, T5, and F6 are cleared. Rows 5 and 6 are hidden (to be revealed again in later code).
Cell F3 is a cell in which user input is required via a validation list. Since the worksheet is protected, it is necessary to unlock range F3 to allow the user to enter data in the cell. EnableEvents is set backto true to allow the worksheet change to trigger when the user enters data in F3.
I am receiving an 'Application-defined or object-defined error' with the line highlighted in red above. (the line that is supposed to unlock cell F3)
View 3 Replies
ADVERTISEMENT
Feb 22, 2008
i have an excel sheet that has a cell with a formula in it. This cell has been locked by the previous user.
I am unable to click on it and it because it is showing a #NAME? error, i need to edit it somehow. Is there some way i can edit it?
View 9 Replies
View Related
Dec 17, 2009
I have a macro in my worksheet that runs as a change event on certain comment cells. This macro unprotects the worksheet, expands the merged comment cell that just change, and re-protects the worksheet. The cell expansion works great. When I re-protect the worksheet all of the cells work correctly, except the cell that was just changed. Any other "unlocked" cell in the document stays unlocked after the protection is applied, but the cell that just changed becomes locked. I need this cell to remain unlocked to allow the user to update the comments. Here is my full
View 3 Replies
View Related
Jan 29, 2007
I have copied from another post (here I believe) and modified for my situtation. I simply want a range of cells K13:U13 to stay locked unless there is an X in H13. This will repeat on down the spreadsheet, ie. K14:U14 will stay locked unless there is a X in H14. Using the script I found it seems to be working unless you go back and change one of the X's to a blank. The range stays unlocked.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strName As String
Dim strRange As String
strName = Me.Range("H13")
If strName = "" Then
Me.Cells.Locked = True
Me.Range("H13").Locked = False
End If
strName = Me.Range("H14")
If strName = "" Then
Me.Cells.Locked = True
Me.Range("H14").Locked = False
End If..................................
View 6 Replies
View Related
Jul 5, 2012
I need to unlock and lock certain cells when other cells have data entered.
I also need to enforce in the unlocked cells a minimum value.
In my worksheet i have the below requirement
Initially Cells C6 and 7 are unlocked and Cells C5, 8 and 9 are locked
1. Cell C6 must have a value entered greater than or equal to 50, when this value is entered I need to unlock cells C5 and C9 and lock cell C7
2. Cell C7 must have a value entered greater than or equal to 50, when this value is entered I need to unlock cells C5 and C8 and lock cell C6
I also need to unlock cells C15 and 16 when C13 has "Yes" selected in the drop down menu.
View 3 Replies
View Related
Oct 25, 2007
I have had a look around and found some answers to this question but not quite as complex and I don't know enough to adapt them correctly.
Basically AX35:AX239 contain a formula which returns "TRUE" or "FALSE" dependant on certain values in the row, what I need is for the corresponding H, I & J cells to be unlocked on each row if the outcome is "TRUE" and no action if "FALSE".
View 9 Replies
View Related
Feb 13, 2014
Excel can automatically recognise individuals by their windows login name so you can fully automate the protect/unprotect of the correct sheets without even individuals having to use passwords.
The first step though would be to gather the id's of all users.
1. Create an additional sheet and call it UserLog
2. Put the following code into all the worksheet code modules
[Code] ......
Once you know the windows login names and which sheet they are responsible for you can add the following code to each worksheet.
[Code] .....
I have tried as per below and it is not working.
I have about 50 user that uses one document and will record their comments to instructions, but only 20 users will be able to add the instructions. The document needs to autolock when it is saved and can only be unlock with the username of the 20 users.
View 1 Replies
View Related
May 7, 2008
I'm using three different workbooks for the macro I've designed. The macro works exactly as I planned it would, but I'm getting a curious side-effect of running the macro. I have over 5,000 workbooks that I need to open, unprotect, change (mostly by copy/paste), and reprotect. It's a fairly straight forward macro, but it is my first, and I must be overlooking something. When the macro is complete, cells that were not modified via the macro in any planned/anticipated way are being unlocked. This has left me puzzled and frustrated. The files are opened, unprotected, the cells are copied over as planned, reprotected, and closed/saved. Everything works perfectly, but the cells in parts of the workbook (Filename) (which were locked before the macro ran) have been unlocked and are no longer protected when the workbook is reprotected. Again, these cells were not within the ranges modified, and I'd rather not have to format every cell in every one of the 5 sheets of (Filename) to be locked.
File names are:
"Finished Goods Inventory TREE (ToDMSI).xls" (alias: Workfile - sheet providing file path to be updated)
"Random_workbook_selected_from_previous_filename.xls" (alias: FileName - the copy-to file being updated)
"MACRO TEST BOM Master.xls" (the copy-from file always open)
Comma Delimited table layout in "Finished Goods Inventory TREE (ToDMSI).xls":
Col A, Col B, Col C, Col D
Customer ID,Item Code,File Name, Directory
4FRE01,4FRE01-0001,4FRE01-0001.xls,4FRONT
Here's the
Public FileName
Public Workfile
Public ItemCode
Public CustCode
Sub OpenBOMSeq()
View 14 Replies
View Related
Oct 22, 2008
The process that will be used is that, I would set up the sheet every month and send it to a data entry person. Then they would send it back to me, and i would send it to certain people for approval. Once they respond with approval I then send it back to the data entry person for filing.
I'm hoping to create a button that will "flip" a switch to to speak.
When I send it to the data entry person the first time, I need certain cells locked and unlocked.
When I send it to the people for approval I need the whole thing locked as well as for when I send it back to the data entry person for filing.
I know how to do this manually, but my issue is that every time I need to send it back to the data entry person at the beginning of the month I have to go over every data entry cell and set it up so that when I lock the sheet they stay unlocked.
So that's where the button would come in...it could even be 2 buttons...Data Entry Locking and then a full Sheet Locking...I would need each password protected too.
View 6 Replies
View Related
Dec 3, 2008
Testing my worksheet, I found that if I double click on any cell that is not locked, the worksheet becomes unprotected. I need to prevent this from happening. I tried the following code, but it didn't work.
View 6 Replies
View Related
Feb 24, 2014
I have a sheet witch has a number of tick boxes and depending on the response a number of hidden rows may open to allow further info to be recorded, how do I protect the sheet in excel 2003 as unlocking certain cells & protecting the sheet will not work.
View 1 Replies
View Related
May 25, 2014
My problem seems quite easy to solve but for some reason I cannot get around the error messages. It seems it will not process the paste values argument:
Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
VB:
Dim currentWb As Workbook
Dim MasterWb As Workbook
Dim wbName As String
Dim ToolWsName As String
Dim MasterWsName As String
Dim k As Integer
[Code] .....
View 3 Replies
View Related
Jul 30, 2009
I am trying to determine how to get the code below to fire whenever cell J10 is populated and do nothing when cell J10 is not populated but I can't quite get it. (Cell J10 is manually changed and is not changed based off of a formula)
View 4 Replies
View Related
Dec 17, 2008
I have a macro that, when run, needs to read the contents of cell B5, and run the code that it contains.
Cell B5, for example, would contain the text:
Range("B13").Formula = "SUM(D12:D14)"
I need a macro to "execute this code", as if it were in the macro itself.
I have assigned the above to a variable, but am not sure how to execute it.
EG.
Dim the_calc
the_calc = Range("B5").value
Now, how do I run the_calc ?
View 9 Replies
View Related
Jan 27, 2009
I use excel 2002 but some of my office are on 97, i want to add a small workbook open event code which works for me but debugs for the others?? The code is basically, go to a tab, on that tab and that range sort..
View 2 Replies
View Related
Feb 8, 2007
I've developed a little software using Excel Macros & VB. To prevent people from accesing the code I protected the code blocking it from visualization. It seems not enough as an acquaintance of a friend cracked it in 25 minutes. Or so he says. So I'd like to know if there is a better way to protect the font code.
View 8 Replies
View Related
Jun 25, 2014
I am attempting to build a mileage tracker based on a master list of code numbers. After submitting the date in cell A, in the next cell, B, I would type a code number from the list, say 7. Seven is the massage parlor that is 15 miles away. So 15 would come up in the next cell C.
View 3 Replies
View Related
Jul 30, 2013
Is this possible using code: Copy Cell A1 and Paste in first empty Cell down Column D. This would be connected to a command button. Both Cell A1 and Column D are on the same spreadsheet.
View 3 Replies
View Related
Mar 29, 2014
I have a spreadsheet with 6 hidden columns (B to G). Rows 1 to 14 are frozen and have data that comes from another work book and these rows will be protected. The user will enter data from H14 to U14 and then H15 to U15 for the next row and so on down the sheet. The number of rows of data over a week is variable, a minimum of 21 rows (3 per day) but no maximum.
When the user starts entering new data in the column range H to U I would like to automatically populate the 6 hidden cells on that row with information from particular cells in protected rows 1 to 14. For example B14 would populate with the value from I4, C14 would populate with the value from I5, D14 from I6, E14 from I7 and so on whenever someone enters a value anywhere from H14 through to U14.
I can understand that a worksheet change event would be useful to do this but I guess then it wouldn't want to run every time each cell is populated so I think if it had to activate on a single cell change then the cell in column L would be best. Also, as I understand it, there can be only one block of code per sheet that operates on a worksheet change event, have I got that right? If that is the case then I assume all the code to populate the hidden cells on each row will need to be in this block of code.
View 8 Replies
View Related
Mar 7, 2012
code which highlights a cell depending on the criteria of another cell.
Example.
In B1 I have the formula =NOW() (we all now what this means).
In B2 I have a completion date.
I would like A2 to fill with a specified colour.
Can this be done so that it works down the whole sheet, if the date is in B5 then only A5 will highlight so basically only the A cell on the same row will change depending on the date in B on the corresponding row?
View 4 Replies
View Related
Feb 18, 2007
In column "L" there is the possibility to have one of the following characters entered as a key for that specific row;
G
X
B
G1
G2
S
Y
H
SB1
SB2
They all have a unique color assigned to them. There are too many for conditional formatting, so I think the way to resolve this is to use VBA. Can I ask for some assistance to get me started?
View 9 Replies
View Related
Apr 28, 2008
I have workbook template that I use to generate reports from a list of depts. This list is contained in a drop down cell that is a named range in a different worksheet. My current process is as follows:
-Select Dept Name from the list
-Click a command button which is assigned to code that calculates and saves to a file
-Repeat for next report until all reports are generated
I would like to automate this process by producing all reports with a single command with the following functionality:
-The Dept Name needs to be populated in the specified cell containing the current drop down because it drive various vlookups and other formulas
-If possible, I would like to retain the drop down functionality as I would like to have the option of running an individual report or running the “batch”.
View 2 Replies
View Related
May 5, 2014
I'm writing some VBA code for Excel. I need to change the color of a cell based upon the data in another cell. This selects sheet "Kane", and searches for the word "Expenses" in a range in column D. Using For-Each, I need the IF statement that will change the cell color in the same row, but in column P.
View 4 Replies
View Related
Feb 28, 2013
I have a protected worksheet with most cells locked and some that are unlocked. I also know the password to unlock the sheet. VBA code to monitor a cell(B29 in my case) and if it has a value of 6.00 or more than it will unlock cell B34?
View 7 Replies
View Related
Sep 3, 2006
working this formula out for use in conditional formatting;
Make E9 show E9+H12 if H9>0
I've got the following formula to conditionally format E9 to red fill when H9>0, but it won't change the contents of E9 to E9+H12 under the same condition;
=IF(H9>0,(H12+E9),"")
View 6 Replies
View Related
Jan 19, 2007
I am trying to create a formula that will reference a cell that contains a zip code and populate another cell with the appropriate technicians ID.
It's simple with one tech covering only one zip code
View 14 Replies
View Related
Mar 9, 2013
I have an excel file having part code,name,vendor and Qty ( Quantity ).
My problem is that I want to apply an excel formula to pick up that vendor code who have highest Qty of a part code.The condition is that S.No.should not be disturbed.This file is so large,but here I have taken an example,
View 2 Replies
View Related
Aug 9, 2013
How to run the macro recorder and have even had a few minor successes with VBA.
I know it's a simple "if-then" code but I can't figure out how to write code that will run a particular macro if a cell contains a certain value.
For example, if the value in cell A1 is "1", then I would like a Macro I've called "Macro1" to run. If the value is "2", run "Macro2", etc.
View 2 Replies
View Related
May 16, 2014
I need a VBA code to take everything after a certain word and put it in a new cell below it. The cell would have View More in it most of the time, and sometimes spaces will be messed up, so it will have a name after it but it should actually be in the cell under it. So if the name is A Maple, it will say View MoreA Maple. So the A Maple need to go in a cell below it.
View 6 Replies
View Related
Jan 17, 2008
It's been about a year since i've used VBA and i need a quick piece of code that will Fill/Shade any cell in my worksheet Red (#FF0000) only IF the date is equal to Today or less...(I need to highlight expired cells)...
Im in Australia, and i know there's an issue between the Aus v US date in Excel...i believe there's a piece of code that can rectify this...
View 14 Replies
View Related