View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default There must be a way!!!--set cells' values equal to calculated values in another range

Make sure events are turned on

manually run a macro like this

Sub TurnOnEvents()
Application.EnableEvents = True
End sub

that will enable events.

Since you have a name like NamesConcatentated (and say "calculated values"),
perhaps this range contains formulas and changes are made in another cell.
If so, try this:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, rng1 As Range
If Target.Count 1 Then Exit Sub
On Error Resume Next
Set rng = Target.Dependents
On Error GoTo 0
If Not rng Is Nothing Then
Set rng1 = Union(rng, Target)
Else
Set rng1 = Target
End If

On Error GoTo ErrHandler

If Not Application.Intersect(rng1, _
Application.Range("NamesConcatenated")) Is Nothing Then
Application.EnableEvents = False
Application.Range("NameValues").Value = _
Application.Range("NamesConcatenated").Value
End If
ErrHandler:
Application.EnableEvents = True
If Err.Number < 0 Then _
MsgBox "Error occured " & Err.Number & vbNewLine & _
Err.Description
End Sub

--
Regards,
Tom Ogilvy


"Arnold" wrote in message
oups.com...
Hi Chip,

Now the column/range "NameValues" does not contain anything--it won't
fill with the values of "NamesContatenated" on worksheet change. No
error though.

The column NameValues should always equal NamesContatenated--when a
user happens to modify a name, the worksheet change event should fire
and the values should be updated. Possible?

Thanks, Eric