Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Probably a dumb question... I'm changing the colour of cells based on what the user inputs (too many options for conditional formatting). Within the "worksheet change" event, I know that "target" is the cell the user is moving to. How do I reference the cell the user is moving from? TIA Damien |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
We need to remember where we came from:
Dim WhereWasI As String Private Sub Worksheet_SelectionChange(ByVal Target As Range) If WhereWasI = "" Then WhereWasI = Target.Address End If MsgBox ("we came from " & WhereWasI) MsgBox ("we now reside at " & Target.Address) WhereWasI = Target.Address End Sub -- Gary''s Student - gsnu200908 "Damien McBain" wrote: Hi, Probably a dumb question... I'm changing the colour of cells based on what the user inputs (too many options for conditional formatting). Within the "worksheet change" event, I know that "target" is the cell the user is moving to. How do I reference the cell the user is moving from? TIA Damien . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I reference the cell the user is moving from?
Hi. Just another idea is to have Excel internally remember where we were. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Application.Goto Target End Sub Then, you access the address via... Function PreviousAddress() PreviousAddress = Application.PreviousSelections(2).Address End Function Sub WhereWasIQ() MsgBox PreviousAddress End Sub Note that if you want to "Go Back" to where you were, don't forget to turn off Events... Sub GoBack() With Application .EnableEvents = False .Goto Range(.PreviousSelections(2).Address) .EnableEvents = True End With End Sub = = = = = = = = = = = = = HTH Dana DeLouis Gary''s Student wrote: We need to remember where we came from: Dim WhereWasI As String Private Sub Worksheet_SelectionChange(ByVal Target As Range) If WhereWasI = "" Then WhereWasI = Target.Address End If MsgBox ("we came from " & WhereWasI) MsgBox ("we now reside at " & Target.Address) WhereWasI = Target.Address End Sub Damien McBain" wrote: Hi, Probably a dumb question... I'm changing the colour of cells based on what the user inputs (too many options for conditional formatting). Within the "worksheet change" event, I know that "target" is the cell the user is moving to. How do I reference the cell the user is moving from? TIA Damien . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to refer cell E53 from the previous (=next left) worksheet? | Excel Discussion (Misc queries) | |||
How to refer cell E53 from the previous (=next left) worksheet? | Excel Programming | |||
Refer to Previous or Next Sheet | Excel Worksheet Functions | |||
Refer to the previous worksheet in a formula | Excel Worksheet Functions | |||
Worksheet Change Event- Refer to Target Address By Name | Excel Programming |