ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   active a set of VBA code once the cell have data. (https://www.excelbanter.com/excel-programming/332073-active-set-vba-code-once-cell-have-data.html)

norika

active a set of VBA code once the cell have data.
 
Dear all,

I am now setting up a simple label template for the junior, and already made
a drop down list through validation function within the range A1:C12.

Once if the user type something in the cell within the range , I want to
execute some VBA coding such as formatting , coping .....etc.

Where should I start to create the coding ? In
Worksheet_SelectionChange(ByVal Target As Range), or Worksheet_Change(ByVal
Target As Range)


Thanks all.






Bob Phillips[_7_]

active a set of VBA code once the cell have data.
 
Change event. Here is an outline of your code

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:C12")) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob Phillips

"norika" wrote in message
...
Dear all,

I am now setting up a simple label template for the junior, and already

made
a drop down list through validation function within the range A1:C12.

Once if the user type something in the cell within the range , I want to
execute some VBA coding such as formatting , coping .....etc.

Where should I start to create the coding ? In
Worksheet_SelectionChange(ByVal Target As Range), or

Worksheet_Change(ByVal
Target As Range)


Thanks all.








mangesh_yadav[_337_]

active a set of VBA code once the cell have data.
 

SelectionChange is triggered when you select the cell, whereas change i
triggered when you change or enter something in a cell. I guess in you
case, change would be better.

Manges

--
mangesh_yada
-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=38000



All times are GMT +1. The time now is 05:44 PM.

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