vba 编程1-100质数从大到小
发布网友
发布时间:2023-11-10 22:30
我来回答
共1个回答
热心网友
时间:2024-11-07 15:30
Sub zs()
Dim i As Integer, ii As Integer, iii As Integer
[A1] = "结果"
For i = 1 To 100
For ii = 1 To i
If (i / ii) = Int(i / ii) Then
iii = iii + 1
End If
Next
If iii < 3 Then
[A65536].End(xlUp).Offset(1, 0) = i
End If
iii = 0
Next
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add Key:=Range("A2:A100") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange Range("A1:A100")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub