Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Running a macro based on a cells value

I have a macro that I want to run when a cells value changes due to a
selection from a list. How can I make this happen? Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Running a macro based on a cells value

As long as you have Excel 2000 up

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$10" Then
'run your macro
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

RP
(remove nothere from the email address if mailing direct)


"Piwo" wrote in message
...
I have a macro that I want to run when a cells value changes due to a
selection from a list. How can I make this happen? Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Running a macro based on a cells value


U¿ytkownik "Piwo" napisa³ w wiadomo¶ci
...
I have a macro that I want to run when a cells value changes due to a
selection from a list. How can I make this happen? Thanks in advance.


try to modify this one
i assumed that you cell is A2

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Address = "$A$2" Then
Application.Run ...' your macro
End If
End Sub

mcg


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Running a macro based on a cells value

Thanks Bob. I will give it a try.

"Bob Phillips" wrote:

As long as you have Excel 2000 up

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$10" Then
'run your macro
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

RP
(remove nothere from the email address if mailing direct)


"Piwo" wrote in message
...
I have a macro that I want to run when a cells value changes due to a
selection from a list. How can I make this happen? Thanks in advance.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Running a macro based on a cells value

I have a cell that contains a drop down list. I want the macro to run if the
list selection changes. For example: I currently selected 60/40 from the
list. If I select 60/40 again, there is obviously no need to re run the
macro. however, if I change the selection to 80/20 I would want to macro to
run.

Clear? Thanks


Dim model As String
Range("k34").Select
model = ActiveCell.Value
Select Case model
Case ""
Exit Sub
Case "60/40"
Sheets("Model Allocation Inputs").Select
Range("D25:D37").Select
Selection.Copy
Sheets("60-40 Charts").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
Case "80/20"
Sheets("Model Allocation Inputs").Select
Range("e25:e37").Select
Selection.Copy
Sheets("60-40 Charts").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
End Select
End Sub

"Macgru" wrote:


U¿ytkownik "Piwo" napisa³ w wiadomo¶ci
...
I have a macro that I want to run when a cells value changes due to a
selection from a list. How can I make this happen? Thanks in advance.


try to modify this one
i assumed that you cell is A2

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Address = "$A$2" Then
Application.Run ...' your macro
End If
End Sub

mcg



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
Running a macro based on the time WNYC Excel Discussion (Misc queries) 1 March 22nd 10 09:45 PM
Macro to highlight cells based on content JimDerDog Excel Worksheet Functions 1 February 1st 06 03:51 PM
Running a macro if any data is entered in a range of cells Jonathan Excel Worksheet Functions 3 November 16th 05 08:38 PM
Running macro on cells that contain formulas Sharon Excel Programming 3 February 28th 05 01:58 PM
How to skip empty cells while running a macro? saziz[_2_] Excel Programming 5 June 10th 04 11:16 PM


All times are GMT +1. The time now is 03:21 AM.

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"