Dim x As Integer '這是在通用中聲明的變量
PRivate Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim num(250), num1 As String
Dim k As Integer
For i = 2 To 51
For j = 1 To 5
num1 = Cells(i, j).Value
If num1 <> "" Then
If Not IsNumeric(num1) Then
MsgBox ("錯誤!請輸入有效數(shù)字(可包括負(fù)數(shù)和小數(shù)及有效的科學(xué)記數(shù)該可)")
Cells(i, j).Value = ""
i = 55
j = 6
k = k - 1
End If
num(k + 1) = Cells(i, j).Value
k = k + 1
End If
Next j
Next i
For i = 1 To k
For j = i + 1 To k
If CSng(num(i)) > CSng(num(j)) Then
num1 = num(i)
num(i) = num(j)
num(j) = num1
End If
Next j
Cells(2 + Int((i - 1) / 5), 7 + (i - 1) Mod 5).Value = num(i)
Next i
If x <> k Then
For i = k + 1 To x
Cells(2 + Int((i - 1) / 5), 7 + (i - 1) Mod 5).Value = ""
Next i
Cells(1, 7).Value = "排序后的數(shù)列如下(共有" & k & "個數(shù))"
x = k
End If
End Sub
新聞熱點
疑難解答
圖片精選