Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Jaymz Brown   on Oct 11 In MS Office Category.

  
Question Answered By: Mansur Bashara   on Oct 11

I don't know the details of your Named_Change subroutine, but something like the
following may work for you:

Public PrevCell As Range

Private Sub Workbook_Deactivate()
Set PrevCell = Nothing
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As
Range)
If Not PrevCell Is Nothing Then
If Len(PrevCell.Value) > 0 Then
Call Named_Change(PrevCell)
End If
End If
Set PrevCell = ActiveCell
End Sub

Sub Named_Change(Rng As Range)
'Expand the text in Rng
Rng.Value = Rng.Value & "X"
End Sub

This method uses a public object variable to keep track of the previous cell.

Copy & paste this into the ThisWorkbook code page of a workbook. Every cell
you change  (after the initial cell) gets an 'X' appended to it as soon as you
move to a different cell, unless you left the cell  empty. You can replace this
dummy Named_Change functionality with the real thing.

By examining the length of the value of PrevCell, you can determine if it is
empty or if it has already been expanded.

Share: 

 

This Question has 13 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Capturing a change BEFORE leaving a cell Or get search suggestion and latest updates.


Tagged: