Consulting

Results 1 to 5 of 5

Thread: Solved: Update UNLOCKED cells on a different sheet?

  1. #1

    Question Solved: Update UNLOCKED cells on a different sheet?

    On Sheet1, users can enter client names (column A) and what date the client last came in to sign paperwork (column B).

    The "paperwork" is on other sheets in the workbook (let's use just Sheet2 for the example).

    Excel then places in column C, what date the client must next sign paperwork on (column B + 182). Columns A and B are unlocked, column C is locked (to do the calculation).

    I would like the user to have the option to update the Sheet1, column B (and thereby, column C) dates whenever they print out the paperwork on Sheet2. Since this is already a complex processor-intensive workbook and we have slow computers, I'd like to do this in a command button as opposed to a Workbook_Change.

    It seems like this could be done with a Replace function, but I know not the syntax. Help?

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    is:
    [vba]Private Sub CommandButton1_Click() 'replace
    With Sheets("Sheet1")
    .Unprotect Password:="password"
    .Range("B4") = Sheets("Sheet2").Range("D2")
    .Protect Password:="password"
    End With
    End Sub[/vba]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Partially there. Problem is, B4 was just the example that corresponds to "Mary". If I was doing the update for "Peter" or "Paul" instead, how do I tell Excel which cell in Sheet1, column B to update?

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    try this one instead:
    [VBA]Private Sub CommandButton1_Click() 'replace
    Dim fRng As Range
    On Error GoTo Nxt
    Sheets("Sheet1").Unprotect Password:="password"
    Set fRng = Sheets("Sheet1").Columns(1).Find(What:=Sheets("Sheet2").Range("B3").Value, After:=Sheets("Sheet1").Range("A1"), LookIn:=xlValues, LookAt:= _
    xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False)
    fRng.Offset(0, 1) = Sheets("Sheet2").Range("D2").Value
    Sheets("Sheet1").Protect Password:="password"
    Exit Sub
    Nxt: MsgBox "Invalid name", vbOKOnly, "Name not found"
    End Sub[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    Excellent! I love discovering new stuff with VBA. Thank you Simon

Posting Permissions

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