Hi there,
Is there way to automatically clear the contents of a cell when the user clicks in that cell. Eg, click in "A1" then then "A1" clears automatically.
Thanks
Hi there,
Is there way to automatically clear the contents of a cell when the user clicks in that cell. Eg, click in "A1" then then "A1" clears automatically.
Thanks
Last edited by staples; 10-15-2009 at 03:48 PM.
Try this, note it will work on all cells so you will probably need to amend it to be more practicalCopy the code![]()
Please Login or Register to view this content.
Select the worksheet in which you the code to run
Right click on the sheet tab and choose View Code, to open the Visual Basic Editor.
Where the cursor is flashing, choose Edit | Paste
Last edited by royUK; 10-13-2009 at 09:11 AM.
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
hi there,
thanks for the reply and suggestion. however, the problem i was having is acutally getting to work for just one cell when it is selected, i am not sure how to do this.
Is this what you mean? The code will only run if A1 is selected
![]()
Please Login or Register to view this content.
Last edited by royUK; 10-14-2009 at 07:31 AM.
My two cents.
I would make it a DoubleClick event.
The problem with deleting something with VBA is that you can't undo it, without some more VBA programming.
The DoubleClick would avoid frustration.
Better yet, I have created a confrimation message window in some of my applications, to give the user a second chance, in case they make a mistake.
modytrane
hi there,
thanks for the code but i cant actually get it to do anything....? I pasted it into the worksheet (sheet1) code area. Is this correct?
I think you understand what I was after though yes. I have a value in A1 which links into the autofilter and will filter out the rest of the worksheet based on the entry in A1. At which point the user can scroll around the sheet as usual.
What I would like is that, when the user clicks into A1 again ready to enter a new value the current cell would automatically clear and be blank, which in turn then filters out all data.
i hope this makes sence
To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.
If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.
Doing this will ensure you get the result you need!
Hi again
Please find the spreadsheet attached below:
When the sheet is first opened, the selections are completely blank, and therefore the filters so no data, which I how I want it. A user will enter a code into B3, eg 2001 or 2004 then the data for the code will display. Then, what I would like, if possible, is that when the user clicks into B3 again, ready to enter a new code, the previous code will be cleared and therefore the entire sheet will be blank again, like when it was first opened.
I hope this clears up and confusion
Thanks again
For a start you cannot have two events for the same object, you are trying to use the selection_change event twice
You have merged Cells B3 to C3, this will cause problems, merged cells should really be avoided. In this case centre across selection from he Format -> Cells menu options is ok.
If you remove the merged cells as above then this code should work
![]()
Please Login or Register to view this content.
It will also be tidier if you replace the formula in E2, = P3, with =IF(ISERROR(P3),"",P3)
hi there,
thanks for your help, its working well!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks