呵呵,第一次写vba,自己解决的,小小庆祝一下

代码出现,(*^__^*) 嘻嘻……,虽然没有女朋友,

但程序解决了,小小庆贺一下

Sub 转换单元格()

'

' Macro1 Macro

'



'

  Dim shtSheet As Worksheet

    For Each shtSheet In Sheets

        If shtSheet.Name = "O3" Then

        For k = 2 To shtSheet.UsedRange.Rows.Count

            For i = 2 To 33

                If (shtSheet.Cells(k, i) = "nodata" Or shtSheet.Cells(2, i) = "") Then

                    shtSheet.Cells(k, i + 33) = "——"

                ElseIf (CInt(shtSheet.Cells(k, i)) < 50) Then

                    shtSheet.Cells(k, i + 33) = "A1"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 50) And (CInt(shtSheet.Cells(k, i)) < 100) Then

                    shtSheet.Cells(k, i + 33) = "A2"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 100) And (CInt(shtSheet.Cells(k, i)) < 120) Then

                    shtSheet.Cells(k, i + 33) = "A3"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 120) And (CInt(shtSheet.Cells(k, i)) < 160) Then

                    shtSheet.Cells(k, i + 33) = "B1"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 160) And (CInt(shtSheet.Cells(k, i)) < 180) Then

                    shtSheet.Cells(k, i + 33) = "B2"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 180) And (CInt(shtSheet.Cells(k, i)) < 200) Then

                    shtSheet.Cells(k, i + 33) = "B3"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 200) And (CInt(shtSheet.Cells(k, i)) < 240) Then

                    shtSheet.Cells(k, i + 33) = "C1"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 240) And (CInt(shtSheet.Cells(k, i)) < 300) Then

                    shtSheet.Cells(k, i + 33) = "C2"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 300) And (CInt(shtSheet.Cells(k, i)) < 360) Then

                    shtSheet.Cells(k, i + 33) = "C3"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 360) And (CInt(shtSheet.Cells(k, i)) < 400) Then

                    shtSheet.Cells(k, i + 33) = "C4"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 400) And (CInt(shtSheet.Cells(k, i)) < 600) Then

                    shtSheet.Cells(k, i + 33) = "D1"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 600) And (CInt(shtSheet.Cells(k, i)) < 800) Then

                    shtSheet.Cells(k, i + 33) = "D2"

                ElseIf (CInt(shtSheet.Cells(k, i)) >= 800) Then

                    shtSheet.Cells(k, i + 33) = "E"

                End If

            Next i

        Next k

    End If

        Exit Sub

    Next shtSheet

    Set shtSheet = Sheets.Add(Before:=Sheets(1))

    shtSheet.Name = "O3"

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值