ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA (https://www.excelbanter.com/excel-discussion-misc-queries/161809-vba.html)

Farhad

VBA
 
Hi,

I have a Data Validation in my sheet and i want to write code that when data
Validation has changed the contents of 2 cells say D4 and D35 would cleared.
Any idea would be much appreciated.

Thanks,
--
Farhad Hodjat

Barb Reinhardt

VBA
 
Try using a worksheet change event.


Right click on the worksheet tab and select VIEW SOURCE.

Paste this

Private Sub Worksheet_Change(ByVal Target As Range)
Dim mySheet As Worksheet
Set mySheet = Target.Parent

If Target.Count 1 Then Exit Sub
If Not Intersect(Target, mySheet.Range("A1")) Is Nothing Then
'Change A1 above as needed.
mySheet.Range("D4").ClearContents
mySheet.Range("D35").ClearContents
End If
End Sub

--
HTH,
Barb Reinhardt



"Farhad" wrote:

Hi,

I have a Data Validation in my sheet and i want to write code that when data
Validation has changed the contents of 2 cells say D4 and D35 would cleared.
Any idea would be much appreciated.

Thanks,
--
Farhad Hodjat



All times are GMT +1. The time now is 07:06 PM.

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