View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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