■ Excel/ㅡExcel VBA Code

엑셀VBA 약수 모두 찾아적기

with seok 2023. 5. 13. 23:43

Sub FindDivisors()
    Dim num As Integer
    Dim i As Integer
    Dim row As Integer
    
    num = Range("A1").Value
    row = 1
    
    For i = 1 To num
        If num Mod i = 0 Then
            Cells(row, 3).Value = i
            row = row + 1
        End If
    Next i
End Sub

728x90