View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Adding data to a cell via VBA


cell refers to the value you need for pressure. Since I have no idea of the
name of the sheet where the event is occuring it wasn't obvious to me that
pressure was to be the cell in column A.

Option Explicit

Dim BackFillConstant As Single
Dim FlowStress As Single
Dim Charpy As Single
Dim FractureArea As Single
Dim Pressure As Single
Dim ArrestPressure As Single
Dim cell As Range

Private Sub Worksheet_Change(ByVal Target As Range)

With Worksheets("Pipeline Data")
BackFillConstant = .Range("K").Value
FlowStress = .Range("FlowStress").Value
Charpy = .Range("CV").Value
FractureArea = .Range("A").Value
ArrestPressure = .Range("ArrestPressure").Value
End With

If Target(1).Column = 1 Then
Application.EnableEvents = False
For Each cell In Target.Columns(1).Cells
If IsNumeric(cell) and len(trim(cell)) < 0 Then
'Pressure = Worksheets("Fracture Velocity").Range("A1").Value
Pressure = cell
cell.Offset(0, 1).Value = _
fnFractureVelocity(BackFillConstant, _
FlowStress, Charpy, FractureArea, _
Pressure, ArrestPressure)
End If
Next
End If

ErrHandler:
Application.EnableEvents = True

End Sub

--
Regards,
Tom Ogilvy


"Aaron1978" wrote
in message ...

Thanks again. Actually, that was another problem I was going to ask you
about. The value that is read from column A is

Pressure = Worksheets("Fracture Velocity").Range("A1").Value

The problem here is that for each succsessive value that is entered in
column A after A1, the function is always reading in the value from A1.
I would like the function to read in each adjacent A value. i.e. A1 to
be used in the function written to B1, A2 to be used in the function
written to B2, etc....

Best Regards,

Aaron


--
Aaron1978
------------------------------------------------------------------------
Aaron1978's Profile:

http://www.excelforum.com/member.php...o&userid=31201
View this thread: http://www.excelforum.com/showthread...hreadid=546244