Delete Formula

ibrahimaa

New Member
Joined
May 22, 2011
Messages
6
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. :cool:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi ibrahimaa

Try this:
Copy this code
Right click on sheet tab
Select “View Code”
Paste

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1") = 1 And Range("A2") = 2 And Range("A3") = 3 Then Range("A1") = ""
End Sub
If user will enter 1 in A1, 2 in A2 then 3 in A3, A1 will be cleared automatically.
 
Upvote 0
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 1 Then

If Target.Offset(-1, 0) = 2 And Target.Offset(-2, 0) = 1 Then
Target.Offset(-2, 0).ClearContents
End If
End If
End Sub
 
Upvote 0
  • Please clarify - were you specifying desired values? Or if they contain any value?
  • Just these cells? Or any time three cells that are vertically contiguous and all three are non-blank, clear the first?
  • @ Steve any time you change a value inside a _Change event handler, you need to toggle EnableEvents lest you inadvertantly create an infinite loop. In this case the values testing will prevent this - but there's always a danger that later on the code gets edited and suddenly what once worked starts locking up Excel due to infinite looping.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,875
Members
452,949
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top