+ Reply to Thread
Results 1 to 11 of 11

Can I get one cell to increase by 1

  1. #1
    Registered User
    Join Date
    01-11-2009
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    53

    Can I get one cell to increase by 1

    I submitted this question in another thread and had some excellent help. The question was if it is possible to increase one cell by 1 when the date was changed in another cell. I installed the code that was given to me and it worked perfectly, thanks agin JB and royuk, UNTIL the cell that was to increase by 1 was locked and the sheet protected. The date cell is not locked.
    Last edited by RMontani; 02-12-2009 at 09:32 PM. Reason: solved

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Can I get one cell to increase by 1

    Change the code to protect the sheet with the UserInterfaceOnly argument set to True. That allows VBA to manipulate the sheet while protecting it from the user interface.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    01-11-2009
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Can I get one cell to increase by 1

    Thanks alot for the help SHG, but I'm not quite expierenced enough to do that. This is the code that I'm using, but J Beaucaire had to write it for me.
    [Code]
    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1")) Is Nothing Then
    Range("B1").Value = Range("B1").Value + 1
    End If
    End Sub
    [code]
    Last edited by RMontani; 02-11-2009 at 08:59 PM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Can I get one cell to increase by 1

    Maybe something like this:

    Please Login or Register  to view this content.
    Be sure to edit that password.

    It also might be
    ActiveWorksheet.Unprotect Password:="secret"
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Can I get one cell to increase by 1

    There is also a code snippet:

    userInterfaceOnly:=True

    ...that would mean the sheet is protected from users making changes, but not VBA. So cell B1 could still be edited by the macro even though it's locked, without having to unprotect it.

    How is the sheet getting protected?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Can I get one cell to increase by 1

    Please Login or Register  to view this content.
    Note Protect, not Unprotect.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Can I get one cell to increase by 1

    Quote Originally Posted by shg View Post
    Please Login or Register  to view this content.
    Note Protect, not Unprotect.
    That's sweet. Never thought of just updating the existing protection. Very nice.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Can I get one cell to increase by 1

    You actually only need to do it in the Workbook Open event.

  9. #9
    Registered User
    Join Date
    01-11-2009
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Can I get one cell to increase by 1

    First I want to apologize for not using tags when I posted that code, I will read up on those now. Second, THANKS again for your help shg and JBeaucaire. I will look at both ways to solve my problem. I'll look into those tags.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Can I get one cell to increase by 1

    Gracias. Mark us up Solved if you would, please.

  11. #11
    Registered User
    Join Date
    01-11-2009
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Can I get one cell to increase by 1

    Just wanted to say thanks to shg and JBeaucaire for all your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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