Check a sheet each time file opened?

D

Don

I have the following in my sheet command.
--------------------------------------------------
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Cells(7, 7).Value = "Processed" Then
Range(Cells(6, 6), Cells(7, 7)).Select
Selection.ClearContents
End If
MsgBox "event happened", vbExclamation
End Sub
-------------------------------------------------
It is to remove what is in cell 6,6 through 7,7 if in cell 7,7 it has
"Processed". I have Excel 2002. It works when Excel is not open and you
open the file from Explore. How can I get it to check each time the file is
opened? Would checking every time the sheet is updated be too much and is
that possible? I have tried using the "Application.EnableEvents" but found
that I did not do it right and when I tested on office 2007 , it went into a
loop and locked Excel.

thanks in advance
 
S

Sheeloo

You can put the code in Worksheet_Activate() so that it gets executed when
you activate the sheet...

Worksheet_Activate()
If Cells(7, 7).Value = "Processed" Then
Range(Cells(6, 6), Cells(7, 7)).Select
Selection.ClearContents
End If
MsgBox "event happened", vbExclamation
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top