View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Can the last two if statements be combined together?

Cells(39, Target.Column).Value = Target.Value

You could also use this line instead of the one above (they will both work
the same)...

Target.Offset(35).Value = Target.Value

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
If I read what you are doing correctly, you should be able to use this
code in place of what you posted...

Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range("C4,E4"), Target) Is Nothing Then
Application.EnableAutoComplete = False
Cells(39, Target.Column).Value = Target.Value
Application.EnableAutoComplete = True
End If
End Sub

Notice that I changed the Range you used in the Intersect function call
from ("C4","E4") to ("C4,E4")... the range you used included the cells C4,
D4 and E4 whereas your subsequent code seemed to indicate that you don't
care about Target being D4.

--
Rick (MVP - Excel)


"Brad" wrote in message
...
If the user change c4, i want the value of c39 to change or
If the user change e4, i want the value of e39 to change

Is there a better way??

Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Range("c4", "e4"), Target) Is Nothing Then
Application.EnableAutoComplete = True
Else
Application.EnableAutoComplete = False
End If
If Intersect(Range("c4"), Target) Is Nothing Then
Application.EnableAutoComplete = True
Else
Range("c39").Value = Range("c4").Value
End If
If Intersect(Range("e4"), Target) Is Nothing Then
Application.EnableAutoComplete = True
Else
Range("e39").Value = Range("e4").Value
End If

End Sub