• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

adding a row at bottom in excel after locking the excel (or)before locking the excel

sony123

Member
i am trying to add a row to Execl at bottom of the sheet. I can select btnAddFacility prior to locking the Excel.
it adds a row at the bottom and i can edit. BUT, once I lock the Excel, the row i added while excel is unlocked is frozen, all the cells.
I can also add a row once the excel is locked, and that seems to work. should i be able to add new row prior to locking?
 
For the first question, you would need to unprotect the cells in the row that you just added for you to still be bale to change them once you protect the sheet.
For the second question, it depends on how the macro is written. Totally possible for the macro to unprotect the sheet, add row, and reprotect. OR, the protection may have the option checked to allow row insertion/deletion.
 
whenever i lock the template using command button,btnAddFacility should be enabled....(so that it should add a new record at the bottom of the excel....)

before locking the excel and after locking the excel new record is adding at the bottom....

but i need to add that record,by locking using command button so that btnAddFacility should be enabled...so that i can add new record at the bottom of the excel.
 
For this to work, will be beneficial if you are using buttons from the ActiveX toolbar. Once that is done, you can do something like:
btnAddFacility.Visible = True

to make that button visible. then, when you have the code unprotect the sheet, do something like:
btnAddFacility.Visible = False
 
yes luke i'm using ActiveX toolbar....

i given code like,
btnAddFacility.enabled = True..in GetLockStatus function....
 
Hi Sony. Buttons do not have an "enabled" property, hence why I posted a Visible command. I don't think it matters where in the code you place it, just needs to be somewhere within the macro where you lock the spreadsheet. All it does is make the button visible/invisible.
 
my code is protecting the sheet....

and i given btnAddFacility.Visible = True in "GetLockStatus" function

GetlockStatus()
btnAddFacility.Visible = True

is that true ....?
 
If your code is in a regular module, and not the sheet module, you'll need to include the parent object like:
Worksheets("Sheet1").MyCheck.Visible = False
 
Also, it might be beneficial if you could post a sample workbook with the buttons of concern, so we can help with the coding better.
 
In your unlocking command, you probably need to add a line to hide the button, something like
Worksheets("Sheet1").btnAddFacility.Visible = False

Make it False when you want to hide the button (when sheet is unlocked), and True when you want it visible (sheet is locked). Also note that you need to make the change during the part of your code when the sheet is unprotected.
 
Hi, sony123!
In general, consider uploading a sample file (including manual examples of desired output if applicable).
In this case, consider uploading/posting the whole code and not just individual lines.
In both cases it'd be very useful for those who read this and might be able to help you. Thank you.
Regards!
 
Back
Top