View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Relative, Offset, ActiveCell


Just to clarify -

If Target = Range("DNine")


Do you intend that line to mean

If the Value in the cell that's just changed is the same as the value in
DNine Then
or
If the cell that's just changed is the DNine cell Then

As written, the code does the former but somehow I suspect you mean the
latter

Regards,
Peter T



"Bob Barnes" wrote in message
...
I'm an Access Programmer using automation to send data to 72 different
Excel
cells.
These 72 cells all have the same relative cell "structure"...IE, the Names
below are
...
"DNine" = I28
"CNine" = H28
"C_D_Nine" = I30

I'm sure I can substitute the Names below so whenever the
Worksheet_Change(ByVal Target As Range) occurs, I can have the ability
to calculate all 72 cell scenarios.

How...relative cell references, "Offset".. ?? TIA - Bob

sample code...
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("DNine") Then
If ((Range("DNine").Value - Range("CNine").Value < 0) _
And Abs(Range("DNine").Value - Range("CNine").Value) 9000) Then
If Len(Range("CNine")) = 4 Then
I = (10000 - Range("CNine").Value)
ElseIf Len(Range("CNine")) = 5 Then
I = (100000 - Range("CNine").Value)
ElseIf Len(Range("CNine")) = 6 Then
I = (1000000 - Range("CNine").Value)
ElseIf Len(Range("CNine")) = 74 Then
I = (10000000 - Range("CNine").Value)
End If
Range("C_D_Nine").Value = Range("DNine").Value + I
Else
Range("C_D_Nine").Value = (Range("DNine").Value - Range("CNine").Value)
End If
End If
End Sub