Action to be carried out only once in VB

marokay

New Member
Joined
Jul 19, 2010
Messages
5
Hello,
I want the action Display in this code:

Code:
Private Sub Worksheet_Calculate()
If Range("I4").Value = "1" And Range("O9").Value = "PLACED" Then Range("O9").ClearContents
If Range("I4").Value = "1" And Range("O11").Value = "PLACED" Then Range("O11").ClearContents
End Sub
Take place only once!
In the case that the conditions are in place it will trigger the deletion of the Q9 or Q11 but if these conditions will come back again he does not erase the cells ...
Is it possible?
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,343
well you need a third condition then and it should be quite permanent.
option 1. reserve a cell somewhere (eventually hidden and locked) to fill in the remarks (as some value) that this has already been done.
option 2. instead of a cell you can create and use a "Custom document property"
 

p45cal

Well-known Member
Joined
Nov 10, 2009
Messages
4,763
In the case that the conditions are in place it will trigger the deletion of the Q9 or Q11 but if these conditions will come back again he does not erase the cells ...
Do you want the two cells to be treated independently? SFor example, if only one of the cells is cleared, do you still want the other cell to be checked?
 

marokay

New Member
Joined
Jul 19, 2010
Messages
5
well you need a third condition then and it should be quite permanent.
option 1. reserve a cell somewhere (eventually hidden and locked) to fill in the remarks (as some value) that this has already been done.
option 2. instead of a cell you can create and use a "Custom document property"
How can I do the first option? (i am a bginer in VB)
 

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,343
Code:
Sheets("Sheet1").Range("A1").Value = "Already Done!"
....
Code:
If NOT Sheets("Sheet1").Range("A1").Value = "Already Done!" Then
            If Range("I4").Value = "1" And Range("O9").Value = "PLACED" Then Range("O9").ClearContents
            If Range("I4").Value = "1" And Range("O11").Value = "PLACED" Then Range("O11").ClearContents
End If
or
Code:
If Sheets("Sheet1").Range("A1").Value = "Already Done!" Then Exit Sub
If Range("I4").Value = "1" And Range("O9").Value = "PLACED" Then Range("O9").ClearContents
If Range("I4").Value = "1" And Range("O11").Value = "PLACED" Then Range("O11").ClearContents
 

marokay

New Member
Joined
Jul 19, 2010
Messages
5
I do not understand how the - "Already Done!" will come in automatically after the cell was deleted ?
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,105,996
Messages
5,508,644
Members
408,689
Latest member
SamSan78

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top