View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Graham[_6_] Graham[_6_] is offline
external usenet poster
 
Posts: 9
Default Cell Change Event

Hi Frank,

Thanks for the error trapping alternative whch works perfectly. One wee
query if I may however is to ask what is the purpose of the Checkspelling in
this particular procedure?

Graham

"Frank Kabel" wrote in message
...
Hi
try the following
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp:
With Target
If .Value < "" Then
Application.EnableEvents = False
.offset(0,1).Value = .value *2.471
End If
.CheckSpelling
End With
CleanUp:
Application.EnableEvents = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany

Graham wrote:
I am trying to get a cell change event procedure to make a
calculation with the data entered in one cell and place that data
into another cell. I am trying something like the procedure below as
an example.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Newrange As Range
Set Newrange = Range("A1")
If Union(Target, Newrange).Address = Newrange.Address Then
Range("B1") = Range("A1") * 2.471
End If
End Sub

The problem is that this works but when I put an entry in cell A1 I
must leave the cell and return to it before the procedure is
activated and the calculation is carried out. Is there a way that the
procedure can be activated whenever the value of A1 is changed.
Grateful for any guidance.

Graham Haughs
Turriff, Scotland