excel 2000

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

Can Excel be used to write a program that evaluates a list
of variables and controls the order of computations by
utilizing "IF ___, THEN ___, ELSE ___" and "GO TO ___"
statements. If so, how?
 
Al

Here's one way

Sub TestCalc()
Dim data1 As Range, data2 As Range
Dim TestVar
Dim result As Double

TestVar = Range("B1")
Set data1 = Range("A4:A7")
Set data2 = Range("B4:B7")

If TestVar > 50 Then
result = Application.WorksheetFunction.Sum(data1)
Else: result = Application.WorksheetFunction.Sum(data2)
End If

Range("B9").Value = result
End Sub

Regards
Peter
 
Back
Top