ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Clearing cells when selecting from a drop down list (https://www.excelbanter.com/excel-worksheet-functions/158076-clearing-cells-when-selecting-drop-down-list.html)

MP

Clearing cells when selecting from a drop down list
 
I have cells on the worksheet that when you select an option from a drop down
list you type in a response. I need to clear these cells as a different
option is selected from the drop down list
i.e A1 - drop down list with options
A2 - cell will change with a a question depending upon what was selected
from A1
A3 - has response typed in i.e like the number 4 - this is what I need to
clear when someone goes back to A1 and selects something different

Thanks in advance
MP

T. Valko

Clearing cells when selecting from a drop down list
 
Try this macro:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
Application.EnableEvents = False
Target.Offset(0, 2).ClearContents
End If
ErrHandler:
Application.EnableEvents = True
End Sub

This assumes you have drop downs in the range A1:10. Change range to suit.

To use this, select the sheet where you want this to happen.
Right click on the sheet tab
Select View Code
Paste the above code into the window that opens
Hit ALT Q or close the window by clicking the X to return to Excel.

--
Biff
Microsoft Excel MVP


"MP" wrote in message
...
I have cells on the worksheet that when you select an option from a drop
down
list you type in a response. I need to clear these cells as a different
option is selected from the drop down list
i.e A1 - drop down list with options
A2 - cell will change with a a question depending upon what was selected
from A1
A3 - has response typed in i.e like the number 4 - this is what I need to
clear when someone goes back to A1 and selects something different

Thanks in advance
MP





All times are GMT +1. The time now is 09:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com