View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] mark.diffley@gmail.com is offline
external usenet poster
 
Posts: 9
Default Using worksheet_change to change value of target cell??

Alright, I got this to work with this code:

If Intersect(Range("b17:k40"), Target) Then
If Target < 1 Then
'x = Target
y = Range("h12").Value
x = Target + y
Range(Target.Address).Value = x
Else
Exit Sub
End If
End If

but if I change a cell outside that range I get an error (Run-time
error '91')

Am I missing something with that intersect command?

Thanks,
Mark

wrote:
Is it possible to change the data within a cell based on what is
entered?

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("C16:F39"), Target) Then

x = Target
Range(Target.Address) = x + Range(F11)

End If

End Sub

I tried using this but got a Run Time '1004' error.

Basically, the user is inputing a number and I want to add a constant
from another cell to this number for the output. I know I can do this
with two tables or two sheets but I was hoping I could have it
automatically update the same cell.


Thanks,

Mark