Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Contents of Last Used Cell

Status
Not open for further replies.

techie99

Programmer
Apr 24, 2003
60
0
0
US
When a user enters a value into a cell and hits enter, the activecell is no longer the cell that the user entered a value into. My question is, how can I delete the contents of the cell that the user just entered data into? Thanks.
 
Place this code in the worksheet (not a module):
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Target.Clear
End Sub

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 



techie99,

The user may hit ENTER. But ENTER does not always act the same on every machine.

The user may also hit the TAB key.

Or the user may hit one of the 4 ARROW keys.

John's code will clear the last entry on every sheet every time. I don't believe that's what you want because you would NEVER be able to enter ANYTHING.

Do you want a button that basically does an UNDO on command?



Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Skip,thanks for your concern. I needed to know this for a if then block of code. So, this will only happen under certain circumstances.

Thanks anotherhiggins for your post. I just had to change it slightly to target.clearcontents, otherwise it would clear the formatting on the cell, when I just wanted to clear what was typed in. Thanks so much.

techie99
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top