Delete Formula

ibrahimaa

New member
Joined
May 22, 2011
Messages
16
Reaction score
0
Points
0
In Excel file, the user will enter 1 in A1, 2 in A2 then if he entered 3 in A3, I want the 1 in A1 (user already entered) to disperse automatically. If Macro is the only way to do this, can I use “record macro” to record specific steps and then run it for example in a command button? I would appreciate any help. :nod:
 

Ken Puls

Administrator
Staff member
Joined
Mar 13, 2011
Messages
2,521
Reaction score
6
Points
38
Location
Nanaimo, BC, Canada
Website
www.excelguru.ca
Excel Version(s)
Excel Office 365 Insider
A macro is the only way, yes. Some questions:
  • So user enters 1 in A1, 2 in A2
  • User then enters 3 in A3 and it clears the value in A1
Now...
  • Are you looking for any value, or only where the entry matches the row number?
  • What happens if a user enters data in A4? Will it clear A2?
  • What happens when they enter data in A1 after the above scenario... does it clear A3 or A2? What is the reason for your selection?
 

ibrahimaa

New member
Joined
May 22, 2011
Messages
16
Reaction score
0
Points
0
Thank you Ken for your support.
For the time being, I want to have it in A1 only where I will develop this to cover other area but after I understand the concept.
I am looking for something like: IF (AND(A3 =True, A1 <> “”), clear A1, 0)
 

Ken Puls

Administrator
Staff member
Joined
Mar 13, 2011
Messages
2,521
Reaction score
6
Points
38
Location
Nanaimo, BC, Canada
Website
www.excelguru.ca
Excel Version(s)
Excel Office 365 Insider
Okay, this will do what you've asked I think. Right click the worksheet, choose View Code, and paste the following in there:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$3" Then
        If Target.Value = True Then Target.Parent.Range("$A$1").ClearContents
    End If
End Sub

This will only fire if the value in A3 is TRUE (so you should set up data validation to enforce that.) If you want it to fire on any value at all, we'll need to adjust it.
 

ibrahimaa

New member
Joined
May 22, 2011
Messages
16
Reaction score
0
Points
0
I think I am doing something wrong. In the attached simple file, 1% will appear automatically in C10 if you checked the check box in B11. You cannot enter a different % in D10 until you unchecked the box.

Check the box, 1% appears, uncheck it and enter a new value in D10; go now to B11 and check the box where the 1% will appear and the value that you entered in D10 still there. It should despair:eyebrows:
Your support is appreciated. Thank you.
 

Attachments

  • 2011 Stipend OP vs 2011 MY (4).xlsm
    27 KB · Views: 21

Bob Phillips

Super Moderator
Staff member
Joined
Mar 21, 2011
Messages
1,940
Reaction score
0
Points
36
Excel Version(s)
O365
Maybe try this
Code:
 Private Sub CheckBox1_Click() Me.Range("$D$10").ClearContents End Sub
 
Top