ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba event (https://www.excelbanter.com/excel-programming/292007-vba-event.html)

Daniel P

vba event
 
Hello

I've created a cell that has a validation list associated to it. Which Event can I use so that it will run that event when and only when that validation range is modified

Currently I've have the macro in the sheet_change section but this mean that it run whenever any change occurs on the sheet and this is useless. I only need it to run if the selection from the validation range change

Thank you for your help

Daniel

Frank Kabel

vba event
 
Hi Daniel
use the worksheet change event and restrict the range it should
process. e.g.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1:A10")) Is Nothing Then Exit Sub
'your code

End Sub

your code is only processed if a single cell in the range A1:A10 is
changed


--
Regards
Frank Kabel
Frankfurt, Germany

Daniel P wrote:
Hello,

I've created a cell that has a validation list associated to it.
Which Event can I use so that it will run that event when and only
when that validation range is modified?

Currently I've have the macro in the sheet_change section but this
mean that it run whenever any change occurs on the sheet and this is
useless. I only need it to run if the selection from the validation
range changes

Thank you for your help,

Daniel



Jim Rech

vba event
 
If Target.Cells.Count 1 Then Exit Sub

So, Frank, if the user selects 2 or more cells in the validation range and
makes a (Ctrl-Enter) change the validation routine is bypassed?<g

--
Jim Rech
Excel MVP



Frank Kabel

vba event
 
Hi Jim
yes, as I wrote :-)
....if a SINGLE cell in ....

But you're right the OP should probably delete this line

--
Regards
Frank Kabel
Frankfurt, Germany

Jim Rech wrote:
If Target.Cells.Count 1 Then Exit Sub


So, Frank, if the user selects 2 or more cells in the validation
range and makes a (Ctrl-Enter) change the validation routine is
bypassed?<g


Frank Kabel

vba event
 
Hi Daniel
good to hear it works for you :-)

--
Regards
Frank Kabel
Frankfurt, Germany

Daniel P wrote:
Thank you very much for your help!

Daniel



All times are GMT +1. The time now is 08:56 PM.

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