ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell range selection after calculation (https://www.excelbanter.com/excel-programming/282332-re-cell-range-selection-after-calculation.html)

Tom Ogilvy

Cell range selection after calculation
 
Dim oldrng as Range
Dim newrng as Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if not newrng is nothing then Set oldrng = newrng
set newrng = Target
End Sub

Private Sub Worksheet_Calculate()
Dim ModifiedCellRange as Range
set ModifiedCellRange = newrng
msgbox modifiedcellrange.Address
End Sub

Calculate fires before SelectionChange, so the most likely trigger for the
calculate is newrng

--
Regards,
Tom Ogilvy


"Edward" wrote in message
...
I need to determine the cell range/address of the last
cell that a calculation was driven off. Essentially, I
want to compare that value with known quantities in other
worksheets that I can already isolate. The problem is
that the code below selects the cell after one has pressed
<ENTER key or used the cursor. As such, I can't use an
offset because of the multiple ways to enter data.
Basically, I need to select the cell before the value has
been changed if you will...or find a way to select that
cell afterwards.

Thanks.

I have been using the following code:

Private Sub Worksheet_Calculate()
Dim ModifiedCellRange as Range
ModifiedCellRange = Selection.Address
End Sub





All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com