VBA学习第二课

Posted yigeduanpian

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VBA学习第二课相关的知识,希望对你有一定的参考价值。

Sub sd()
Dim i As Integer
For i = 2 To 2000

    If Range("b" & i) = "" Then
    Exit For
    End If


    If Range("b" & i) = "理工" Then
    Range("c" & i) = "LG"
    ElseIf Range("b" & i) = "文科" Then
    Range("c" & i) = "WK"
    Else: Range("c" & i) = "CJ"
    End If
Next

End Sub

  

Sub aa()



Dim i As Integer


For i = 2 To 2000
    If Range("e" & i) = "" Then
    Exit For
    End If
    
    If Range("e" & i) = "男" Then
    Range("f" & i) = "先生"
    Else: Range("f" & i) = "女士"
    End If
Next

  

Sub aa()

Dim i As Integer

For i = 26 To 2 Step -1 ‘往回删除需要加个 step -1

    If Range("D" & i) = "" Then
    
    Range("D" & i).Select
    
    Selection.EntireRow.Delete
        
    End If
    
Next



End Sub

  

Sub aa()

Dim i As Integer


For i = 3 To 200 Step 2

    If Range("a" & i) = "" Then
    Exit For
    End If
    
    Rows("1:1").Select
    Selection.Copy
        Range("a" & i).Select
        Selection.Insert Shift:=xlDown
    
    Next
    

End Sub

  

Sub 个税()

Dim i As Integer

For i = 2 To 200

    If Range("c" & i) = "" Then
    Exit For
    End If
    
    If Range("c" & i) - 3500 <= 0 Then
        Range("d" & i) = 0
        ElseIf Range("c" & i) - 3500 > 0 And Range("c" & i) - 3500 <= 1500 Then
        Range("d" & i) = (Range("c" & i) - 3500) * 0.03
        ElseIf Range("c" & i) - 3500 > 1500 And Range("c" & i) - 3500 <= 4500 Then
        Range("d" & i) = (Range("c" & i) - 3500) * 0.1 - 105
        ElseIf Range("c" & i) - 3500 > 4500 And Range("c" & i) - 3500 <= 9000 Then
        Range("d" & i) = (Range("c" & i) - 3500) * 0.2 - 555
        ElseIf Range("c" & i) - 3500 > 9000 And Range("c" & i) - 3500 <= 35000 Then
        Range("d" & i) = (Range("c" & i) - 3500) * 0.25 - 1005
        ElseIf Range("c" & i) - 3500 > 35000 And Range("c" & i) - 3500 <= 55000 Then
        Range("d" & i) = (Range("c" & i) - 3500) * 0.3 - 2755
        ElseIf Range("c" & i) - 3500 > 55000 And Range("c" & i) - 3500 <= 80000 Then
        Range("d" & i) = (Range("c" & i) - 3500) * 0.35 - 5505
        ElseIf Range("c" & i) - 3500 > 80000 Then
        Range("d" & i) = (Range("c" & i) - 3500) * 0.45 - 13505
    End If
Next


End Sub

  

以上是关于VBA学习第二课的主要内容,如果未能解决你的问题,请参考以下文章

Python学习,第二课 - 字符编码

学习linux第二课

C 语言学习第二课

《ASP.NET SignalR系列》第二课 SignalR的使用说明

人工智能第二课 机器学习 Orange 开源项目

第二课 如何学习Python编程?