excel中if语句用vba怎么写
比如单元格中的公式是:b1=if(a1>=80,"A",if(a1>=60,"B","C"))这是想把11科的分数改成像公式里一样的abc等,我不想用公式,这个公式在vb...
比如单元格中的公式是:b1=if (a1>=80,"A",if(a1>=60,"B","C"))这是想把11科的分数改成像公式里一样的abc等,我不想用公式,这个公式在vba中怎么写因为有11科,所有就会有,有11列,60多行,有没有简便方法,比如调用过程等能让vba运行得快些而且VBA代码还没有太多重复,不乱套
展开
3个回答
2013-07-29
展开全部
Dim I As Integer
Private Sub Worksheet_Change(ByVal Target As Range) For I = 1 To 100 If Range("a" & I).Value <> "" Then If Range("a" & I).Value >= 80 Then Range("b" & I).Value = "A" ElseIf Range("a" & I).Value >= 60 Then Range("b" & I).Value = "B" Else Range("b" & I).Value = "C" End If End If NextEnd Sub
Private Sub Worksheet_Change(ByVal Target As Range) For I = 1 To 100 If Range("a" & I).Value <> "" Then If Range("a" & I).Value >= 80 Then Range("b" & I).Value = "A" ElseIf Range("a" & I).Value >= 60 Then Range("b" & I).Value = "B" Else Range("b" & I).Value = "C" End If End If NextEnd Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-29
展开全部
Public Function dj(A As Integer)
Dim Rst As String
Rst = ""
Select Case A
Case Is >= 80
Rst = "A"
Case Is >= 60
Rst = "B"
Case Else
Rst = "C"
End Select
dj = Rst
End Function
Dim Rst As String
Rst = ""
Select Case A
Case Is >= 80
Rst = "A"
Case Is >= 60
Rst = "B"
Case Else
Rst = "C"
End Select
dj = Rst
End Function
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询