View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Help with 1 code line

I've added a few checks and disabled events while the thing is running,
(probably not needed, but you do want to err on the safe side. and you
may have other event handlers on the sheet or book)

Since you run in an object module i've used the Me keyword, with
evaluates to the sheet in which the code is running.

Also I've changed to sequence of color and goto
First reset the color, THEN jump to prevselect


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range,
Cancel As Boolean)

If Not Intersect(Target, Me.Columns(2)) Is Nothing Then
Cancel = True
With Application
.EnableEvents = False
Me.Range("B4").CurrentRegion.Interior.ColorIndex = xlColorIndexNone
'or .Entirerow.Interior.ColorIndex = xlColorIndexNone
If Not .PreviousSelections(1) Is Nothing Then
.Goto Reference:=.PreviousSelections(1)
End If
.EnableEvents = True
End With
End If

End Sub

hth...

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"JMay" wrote:

Below code in Sheet2 allows user to return to previous clicked cell in
Sheet1:
My Sheet1 code (not shown) Highlights ActiveRow (on Sheet2) setting
interior = 3.
4th line of code below is my attempt to remove colorindex when
retuning to sheet1,
however it "ain't-working". Any help appreciated.
TIA,


Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
If Not Intersect(Target, Range("B:B").EntireColumn) Is Nothing Then
Cancel = True
Application.Goto Reference:=Application.PreviousSelections(1)
ActiveSheet.Range("B4").CurrentRegion.Rows.Interio r =
xlColorIndexNone
<<BOMB!!
End If
End Sub