View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Piwo Piwo is offline
external usenet poster
 
Posts: 9
Default list + macros continued

The macro as it currently exists...




Sub Copy_Model()
'
' Copy_Model Macro
'
'
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Static prevValue

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K34")) Is Nothing Then
With Target
If .Value < prevValue Then
Select Case .Value
Case ""
Exit Sub

Case "20/80"
Sheets("Model Allocation Inputs").Select
Range("Model20_80").Select
Selection.Copy
Sheets("Model Chart").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
Case "40/60"
Sheets("Model Allocation Inputs").Select
Range("Model40_60").Select
Selection.Copy
Sheets("Model Chart").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
Case "60/40"
Sheets("Model Allocation Inputs").Select
Range("Model60_40").Select
Selection.Copy
Sheets("Model Chart").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
Case "80/20"
Sheets("Model Allocation Inputs").Select
Range("Model80_20").Select
Selection.Copy
Sheets("Model Chart").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
Case "100/0"
Sheets("Model Allocation Inputs").Select
Range("Model100_0").Select
Selection.Copy
Sheets("Model Chart").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
End Select
End Select
Else
prevValue = .Value
End If
End With
Me.Select
End If
ws_exit:
Application.EnableEvents = True
End Sub


Option Explicit
Private m_vChangeValue As String

"Bob Phillips" wrote:

Not tested, but this should work

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Static prevValue

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("K34")) Is Nothing Then
With Target
If .Value < prevValue Then
Select Case .Value
Case ""
Exit Sub
Case "60/40"
Sheets("Model Allocation Inputs").Select
Range("D25:D37").Copy
Sheets("60-40 Charts").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
Case "80/20"
Sheets("Model Allocation Inputs").Select
Range("e25:e37").Copy
Sheets("60-40 Charts").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
End Select
Else
prevValue = .Value
End If
End With
Me.Select
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)


"Bob Phillips" wrote in message
...
Static prevValue
Dim model As String
Range("k34").Select
model = ActiveCell.Value
If model < prevValue Then
Select Case model
Case ""
Exit Sub
Case "60/40"
Sheets("Model Allocation Inputs").Select
Range("D25:D37").Copy
Sheets("60-40 Charts").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
Case "80/20"
Sheets("Model Allocation Inputs").Select
Range("e25:e37").Copy
Sheets("60-40 Charts").Select
Range("F39").Select
ActiveSheet.Paste Link:=True
End Select
Else
prevValue = model
End If


--

HTH

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


"Piwo" wrote in message
...
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