2016年4月9日 星期六

Dim num1 As Integer

Sub test1()

Range("a1").Value = num1

End Sub

Sub test2()
Range("a2:a50").Value = "vvv"
End Sub


Sub test3()
Range("a2:a50").Clear
End Sub



Sub test4()
Dim i, Sumtotal As Integer

Range("a:d").Clear

Range("a1").Value = "編號"
Range("b1").Value = "分數"
Range("c1").Value = "是否及格"
Range("d1").Value = "評等"

For i = 1 To 10
   Range("b" & i + 1).Value = "=RANDBETWEEN(1,100)"
Next
'  錄巨集
    Range("B2:B11").Select
    Selection.Copy
    Application.CutCopyMode = False
    Selection.Copy

    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
' 案esc
    Application.CutCopyMode = False
    Range("A1").Select

For i = 1 To 10 Step 1
    Sumtotal = Sumtotal + Range("b" & i + 1).Value

    Range("a" & i + 1).Value = i

If Range("b" & i + 1).Value >= 60 Then
    Range("c" & i + 1).Value = "及格"
Else
    Range("c" & i + 1).Value = "不及格"
End If



Select Case Range("b" & i + 1).Value

    Case Is < 0, Is > 100
       Range("d" & i + 1).Value = "分數輸入錯誤"
    Case Is >= 80
       Range("d" & i + 1).Value = "a"
    Case 70 To 79
       Range("d" & i + 1).Value = "B"
    Case 60 To 69
       Range("d" & i + 1).Value = "C"
    Case Else
        Range("d" & i + 1).Value = "d"
End Select
   
    Range("a13").Value = "總成績" & Sumtotal
   
   
Next

End Sub


0 意見:

張貼留言

標籤

總網頁瀏覽量

Translate

Popular Posts

Blog Archive