Function IsArmstrong(m As Long) As Boolean
Dim s As Long, n As Integer, i As Integer, m1 As Long
Dim d(1 To 15) As Long
m1 = m: n = 0
Do While m1 > 0
n = n + 1
d(n) = m1 Mod 10
m1 = Int(m1 / 10)
Loop
s = 0
For i = 1 To n
s = s + d(i) ^ n
Next i
IsArmstrong = (s = m)
End Function
Sub Test()
Dim k As Long, i As Long, j As Integer
Cells.Clear
k = CLng(InputBox("Введите значение k"))
j = 1
For i = 0 To k
If IsArmstrong(i) Then
Cells(j, 1) = i
j = j + 1
End If
Next i
End Sub