![]() |
Address of Selection Prior to Clicking on a Cell
If I have cell b5 selected, and I click on cell e5, is there a way for
VBA to identify that it came from cell b5 before the click? Code such as this can be set to be triggered when you click on a cell, but can it tell you what cell it came from? Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("B5")) Is Nothing Then _ Range("B5").Value = 10 End Sub Thank you, Chris |
Address of Selection Prior to Clicking on a Cell
Try the below..
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static pRange As Range If Not pRange Is Nothing Then MsgBox "Previous target " & pRange.Address Set pRange = Target End Sub -- Jacob "axle" wrote: If I have cell b5 selected, and I click on cell e5, is there a way for VBA to identify that it came from cell b5 before the click? Code such as this can be set to be triggered when you click on a cell, but can it tell you what cell it came from? Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("B5")) Is Nothing Then _ Range("B5").Value = 10 End Sub Thank you, Chris . |
All times are GMT +1. The time now is 06:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com