View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default list + macros continued

Try this...

Option Explicit
Private m_vChangeValue As String

Private Sub Worksheet_Change(ByVal Target As Range)
Dim wksFrom As Worksheet
Dim wksTo As Worksheet

If Target.Address = "$K$34" Then
Set wksFrom = Sheets("Model Allocation Inputs")
Set wksTo = Sheets("60-40 Charts")

Select Case Target.Value
Case ""
Exit Sub
Case "60/40"
If Target.Value < m_vChangeValue Then
wksFrom.Range("D25:D37").Copy
wksTo.Range("F39").Paste Link:=True
End If
Case "80/20"
If Target.Value < m_vChangeValue Then
wksFrom.Range("E25:E37").Copy
wksTo.Range("F39").Paste Link:=True
End If
End Select
End If
m_vChangeValue = Target.Value
Set wksFrom = Nothing
Set wksTo = Nothing
End Sub

This code needs to be pasted into the sheet where you want to update Cell
k34. Right Click on the sheet. Select View Code. Paste this into the code
window... I am not running Excel 2003 so I do not have the link property here
at work, but this should do what you need it to do.

HTH

"Piwo" wrote:

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