+ Reply to Thread
Results 1 to 13 of 13

How to make a locked cell auto update

  1. #1
    Registered User
    Join Date
    02-18-2014
    Location
    Gold Coast, Australia
    MS-Off Ver
    Office 365
    Posts
    8

    How to make a locked cell auto update

    Hello everyone, this is my very first time posting.

    I have the following code which is set up, basicly I want to have cell O2 auto update when I click the button I have added.

    It works fine if I do not lock the cell, but if I don't lock the cell it clears it back to blank as I have all unlocked cell being cleared as well.
    Any help would be greatly appreceated.

    Thanks

    mclark15


    Cell O:2 is set up for auto invoice number and I also have code there for clearing unlocked cells. If I lock cell O:2 it does not work.
    Is there a way to lock this cell and still get the auto numbering code to work.


    Sub SaveAs()
    Const Variable1 As String = "22032011"
    Application.Dialogs(xlDialogSaveAs).Show "Report" & Variable1 & ".xls"
    Range("O2").Value = Range("O2").Value + 1
    Dim ws As Worksheet
    Dim xshape As Shape
    For Each ws In ThisWorkbook.Worksheets
    For Each xshape In ws.Shapes
    If xshape.Type = msoFormControl Then
    xshape.ControlFormat.Value = False
    End If
    Next
    Next
    Dim c As Range
    For Each c In Sheets("FrameChecklist").UsedRange
    If c.Locked = False Then
    c.Value = ""
    End If
    Next
    End Sub
    Last edited by mclark15; 02-18-2014 at 08:23 PM.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: How to make a locked cell auto update

    Hi mclark15,

    Welcome to the forum. When posting code please use code tags. It maintains formatting and makes code easier to read. To use code highlight your code and press the # in the toolbar. You might try:
    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    02-18-2014
    Location
    Gold Coast, Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: How to make a locked cell auto update

    Hi Thanks for the quick reply.

    I pasted in the code you sent back and it came up with the following error,

    Run-time error '1004':
    Method 'Range' of object'_Global' failed.

    My code now looks like this.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-18-2014
    Location
    Gold Coast, Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: How to make a locked cell auto update

    Is it also posible to clear out the follow unlocked cells, and if so how would it go.
    C18, C25, C37, C45,
    C47, A48 & A49

    Thanks again

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: How to make a locked cell auto update

    My mistake I put a zero in place of the letter O. Try:
    Please Login or Register  to view this content.
    On your second question, it might look something like this:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-18-2014
    Location
    Gold Coast, Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: How to make a locked cell auto update

    Hi again

    where in the code would you recommend that i paste the .ClearContents

    mclark15

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: How to make a locked cell auto update

    Well lets step back and figure out exactly what you're trying to do. I thought this was two different issues.

    Why and how are you locking sells? When and why do you want to clear the contents?

  8. #8
    Registered User
    Join Date
    02-18-2014
    Location
    Gold Coast, Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: How to make a locked cell auto update

    Sorry to be confusing,
    What I am trying to do is have 1 reset form button on the page.
    When it is pressed I want it to do.
    1) bring up the saveAs dialog box so that it can saved to specific folder (i want to choose where to save it)
    2a) Reset the template I was originaly working on with all check boxes cleared.
    2b) Reset the template with any data that has been added in unlocked cells is cleared
    2c) Save the template with the next (lets say Invoice) number

    I have cells locked & the worksheet protected so that there is no chance of this worksheet being changed in the event of user error.
    If i dont lock cell O2 it gets cleared when I run the macro, if I lock it it doesnt work.

    Hope this helps

  9. #9
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: How to make a locked cell auto update

    Try this:
    Please Login or Register  to view this content.
    Don't manually lock or protect the sheet. It will protect itself automatically every time it is activated but allow for changes to made through code only.

  10. #10
    Registered User
    Join Date
    02-18-2014
    Location
    Gold Coast, Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: How to make a locked cell auto update

    Great this ran ok the only thing is that it does not save the template sheet with the next number.
    and when the new one is saved it adds the number there which needs to change on the template, the other thing is that it also clears the checked boxes on the SaveAs sheet.

  11. #11
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: How to make a locked cell auto update

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    02-18-2014
    Location
    Gold Coast, Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: How to make a locked cell auto update

    Thankyou so much, I have learnt alot due to your help.

    Thanks Again

  13. #13
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: How to make a locked cell auto update

    Glad to help. And thank you for marking the post as solved.

    On any thread you can show your appreciation to those who have helped you by clicking the * below their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Locked some cell and make if function
    By okyjelly in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-20-2013, 09:57 PM
  2. Replies: 1
    Last Post: 01-09-2011, 11:08 PM
  3. Locked choices in dropdown cell and auto go to...
    By Getalinks in forum Excel General
    Replies: 14
    Last Post: 03-25-2010, 06:55 PM
  4. Make a cell grey and locked
    By SFFliberte in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-15-2009, 09:30 PM
  5. Pivot talbe, how to make it to auto update
    By feejo in forum Excel General
    Replies: 1
    Last Post: 06-02-2007, 12:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1