View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Using code to calculate a value in the next row

How do you intend to inform the code which column to use? How do you
intend to determine what row to use?

Public function GenBbasedOnA( vVal)
Select Case vVal
Case 5
GenBbasedOnA = 5
Case 4
GenBbasedOnA = 4.4
Case 3
GenBbasedOnA = 3.4
Case 2
GenBbasedOnA = 2
Case 1
GenBbasedOnA = 1
Case Else
GenBbasedOnA = 0
End Select
End Function


Sub Tester1()
ActiveCell.Offset(0,1).Value = GenBbasedOnA(ActiveCell.Value)
End Sub


--
Regards,
Tom Ogilvy

"Barth Wilsey" wrote in message
news:DKFzb.301739$ao4.1040193@attbi_s51...
I want to use code to calculate a predetermined value depending upon the
result of an experiment
I would put the result in Column A and would want the predetermined value

to
appear in the same row in Column B
I would want to do this with multiple columns so I would not want to hard
code the column name
Can this be done?

Private Sub Column A cell_AfterUpdate()
Select Column A cell
Case 5
Column B cell = 5
Case 4
Column B cell = 4.4
Case 3
Column B cell = 3.4
Case 2
Column B cell = 2
Case 1
Column B cell = 1
End Select