ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   assign a macro (https://www.excelbanter.com/excel-discussion-misc-queries/91220-assign-macro.html)

daidipya

assign a macro
 
Hi

In my worksheet at cell B10 the drop down has a selection of either
YES or NO. After i select YES or NO then to run the macro assigned to
this i have select the Tolls then Macro then Macro and then run the
macro. instead i want the macro to run automatically on selection of
either YES or NO.

please guide me.

regards

daidipya


Ardus Petus

assign a macro
 
In Worksheet's code, paste the following (adapt to your needs):

HTH
--
AP

'---------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rWatch As Range
Set rWatch = Range("B10")
If Intersect(Target, rWatch) Is Nothing Then Exit Sub
Call myMacro(rWatch.Value)
End Sub

Sub myMacro(sVal As String)
MsgBox sVal
End Sub
'-------------------------------------

"daidipya" a écrit dans le message de news:
...
Hi

In my worksheet at cell B10 the drop down has a selection of either
YES or NO. After i select YES or NO then to run the macro assigned to
this i have select the Tolls then Macro then Macro and then run the
macro. instead i want the macro to run automatically on selection of
either YES or NO.

please guide me.

regards

daidipya




daidipya

assign a macro
 
Thanks for the expeditious reply.

but i do not know anything about the vba so i have not understood
where to paste the above said code.


Ardus Petus

assign a macro
 
Right-click on your Worksheets's tab (down left)
Select View code
This will open a new window, where you paste my code.

If you're stuck, please post back!

HTH
--
AP

"daidipya" a écrit dans le message de news:
...
Thanks for the expeditious reply.

but i do not know anything about the vba so i have not understood
where to paste the above said code.




daidipya

assign a macro
 
this is amazing - i mean to say that for the first time i have come to
know about the google group and all this stuff. thanks once again for
your reply i did the same but the result what i want i ma not getting.

i have one macro as follows
Sub HideRows()
Dim Rng As Range
Set Rng = Sheets("Sheet1").Range("B10")
If Rng.Value = "YES" Then
Rows("11:50").EntireRow.Hidden = False
Range("B11").Select
ElseIf Rng.Value = "NO" Then
Rows("11:50").EntireRow.Hidden = True
Range("B51").Select
End If
End Sub


now this macro i want to assign to YEs or NO. when i pasted the code
that you have given, i got a result of No or Yes instead of hiding or
unhiding of the rows.

ealrier i used to think that i know a lot about excel but now i am
realising that i know nothing , even though i am a finance guy. i hope
you would be able to sort my tiny problem



All times are GMT +1. The time now is 02:20 AM.

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