Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Trenton, Ontario
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remove cell contents (office 2000)

    Could someone please help with a quick Macro. I have a workbook with two worksheets in it. The first sheet requires the user to type in some information into cells B12 to B18. When they are done they go to sheet #2 and print out the form they require (using, in part, that information). I need a macro that will automatically clear cells B12 to B18 on sheet #1 when the user goes back to sheet #1 from sheet #2. I only need the cells cleared when they go from sheet 2 to 1, not 1 to 2.
    Thank you in advance for any help you can give.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Remove cell contents (office 2000)

    Place the following code in the Sheet1#1 code pane :<pre>Private Sub Worksheet_Deactivate()
    If ActiveSheet.Name = "Sheet2" Then
    Me.[B12:B18].ClearContents
    End If
    End Sub</pre>

    To enter the code, right click on the sheet tab of sheet#1 and select View Code, and enter the above in the code window.

    You can of course change "Sheet2" to whatever the name of your sheet#2 is.

    Andrew C

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Remove cell contents (office 2000)

    Sorry, mis read your requirements:

    Enter the following code in Sheet2 <pre>Private Sub Worksheet_Deactivate()
    If ActiveSheet.Name = "Sheet1" Then
    ActiveSheet.[B12:B18].ClearContents
    End If
    End Sub</pre>

    Use the same method to enter the code, except use the shett tab of sheet#2, and change sheetname sheet1 if necessary

    Andrew C

  4. #4
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Trenton, Ontario
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Remove cell contents (office 2000)

    Thank you very much Andrew, it worked like a charm!!!
    I appreciate your help.
    David

Posting Permissions

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