#1   Report Post  
Posted to microsoft.public.excel.misc
daidipya
 
Posts: n/a
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
Ardus Petus
 
Posts: n/a
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
daidipya
 
Posts: n/a
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.misc
Ardus Petus
 
Posts: n/a
Default 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.



  #5   Report Post  
Posted to microsoft.public.excel.misc
daidipya
 
Posts: n/a
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create a command button, then assign macro to it in excel kshaheen Excel Discussion (Misc queries) 3 June 24th 08 01:03 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
assign macro PH NEWS Excel Worksheet Functions 2 February 28th 06 02:17 PM
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"