ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run a marco automatically (https://www.excelbanter.com/excel-programming/329227-run-marco-automatically.html)

Dennis Cheung[_2_]

run a marco automatically
 
i need a marco runs automatically after a selection in page area (i wonder
if it is called page area). is it possible? how to write the code?

example:
there are mutiple shops sales data in a pivot table. i want the marco to run
automatically after i select a different shop. since there are 2 tables in
one sheet. i need to merge 2 tables after selecting a different shop?

please help!

Dennis



Carim[_3_]

run a marco automatically
 
Dennis,

Have you sorted out your "custom sort" ?


Dennis Cheung[_2_]

run a marco automatically
 
thanks Carim! it all works. really appreciate for your kind assistance.

"Carim" wrote in message
oups.com...
Dennis,

Have you sorted out your "custom sort" ?




Vinit[_2_]

run a marco automatically
 
Hi Dennis,
The solution provided by Carim is appropriate for yor problem.
To run marco automatically after a selection:

Call the macro in "Worksheet_SelectionChange" event.

Here even you can restrict the macro call to particular range by
checking the Target parameter of event.

Regards.


Dennis Cheung[_2_]

run a marco automatically
 
Dear Vinit,

Since I am not familar to VBA. Can you explain more specific?
The selection is in range b2 and the marco name is marco1.

Dennis

"Vinit" wrote in message
oups.com...
Hi Dennis,
The solution provided by Carim is appropriate for yor problem.
To run marco automatically after a selection:

Call the macro in "Worksheet_SelectionChange" event.

Here even you can restrict the macro call to particular range by
checking the Target parameter of event.

Regards.




Vinit[_2_]

run a marco automatically
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 2 and Target.Row= 2 Then 'For B2
ShowCellValue' macro1
End If
End Sub

Sub ShowCellValue() 'My Macro. macro1 in ur case
MsgBox "The value =" & ActiveCell.Value
End Sub



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

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