Like the title says, I have a set of numbers in A1:A5 and I want to be able to press a button and run a formula (power in this case) on each cell and return the results in B1:B5.

So it would look like this:

A B
2 4
3 9
3 9
5 25
2 4

I am very much a begginer when it comes to macros, but I am trying to learn my way through them. I could do single value things fine (and I know I can do all this through functions in Excel but I want to know how to do it as a macro)

Here is my current code:

Sub Button1_Click()

Range("B1:B5").Value = Application.WorksheetFunction.Power(Range("A1:A5"), 2)

End Sub


Thanks!