Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I should also mention that this macro must be placed in the sheet module of
the sheet that contains the K2 cell in question. To access that module, right-click on the sheet tab, select View Code, and paste the macro into that module. You mentioned that you had your macro in "ThisWorkbook". I take that to mean the ThisWorkbook module. That is the workbook module and that is not the right module for this macro. HTH Otto "Otto Moehrbach" wrote in message ... Don't know exactly what you are wanting to do. The Change macro is written: Private Sub Worksheet_Change(ByVal Target As Range) End Sub Leave those two line alone. If you want the macro to call the getRvalues macro when K2 changes, do this: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address(0,0) = "K2" Then Call getRvalues End Sub If you want to set myRange for some reason use: Private Sub Worksheet_Change(ByVal Target As Range) Dim myRange As Range Set myRange = Worksheets(1).Range("K2") If Target.Address(0,0) = "K2" Then Call getRvalues End Sub But I don't know what you want to do with myRange. If Worksheets(1) is the sheet that holds this code, just say Set myRange = Range("K2") HTH Otto "Pflugs" wrote in message ... I am trying to write a macro that pulls R values from trendlines any time a common variable is changed. The variable is stored in "k2," and I have tried to run this using the following code placed in "ThisWorkbook": Public myRange As Range Set myRange = Worksheets(1).Range("K2") Private Sub Worksheet_SelectionChange(ByVal myRange As Excel.Range) Call getRvalues End Sub It's not working, and I'm not sure why. I bet it has something to do with my range declaration, but can someone confirm that? When I'm working with events, what's the proper way to declare variables and objects relating to these events? Thanks, Pflugs |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to use selection change instead of double click event? | Excel Discussion (Misc queries) | |||
Selection Change Event | Excel Programming | |||
Selection Change Event | Excel Programming | |||
Selection Change Event... | Excel Programming | |||
Autofilter.Selection - After Change Event??? | Excel Programming |