excel函数分段计算

lookup(A1,{0,50,60,70,80,90},{1,2,3,4,5,6})

if(a1<50,a1*2,if(a1>50,if(a1<60,a1+26,if(a1>60,a1/23))))

Sub Procedure() Select Case [A1] Case Is < 50 [B1] = [A1] * 2 Case Is < 60 [B1] = [A1] + 26 Case Is > 60 [B1] = [A1] / 23 End Select End Sub 然后按 Alt+F8,再执行Procedure。 如果要 B1 单元格内是公式,就用: Sub Procedure() Select Case [A1] Case Is < 50 [B1].Formula = “=A1*2″ Case Is < 60 [B1].Formula = “=A1+ 26″ Case Is > 60 [B1].Formula = “=A1/23″ End Select End Sub 如果要 A 列几个单元格重复: (假定是 A1 到 A5) Sub Procedure() For i = 1 To 5 Select Case Cells(i, 1) Case Is < 50 Cells(i, 2) = Cells(i, 1) * 2 Case Is < 60 Cells(i, 2) = Cells(i, 1) + 26 Case Is > 60 Cells(i, 2) = Cells(i, 1) / 23 End Select Next i End Sub



发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(Spamcheck Enabled)