how do i square all items in a colums w/out doinf it one-by-one?

E

excellent person

I used the random number generator to generate 1000 numbers. Now I want to
square all 1000 items but obviously I dont want to do it one-by-one. How can
I do this instantly?
 
N

Norman Jones

Hi Excellent Person.

Try:

'============>>
Sub SquareEm()
Dim Rng As Range
Dim rCell As Range

Set Rng = Selection
For Each rCell In Rng.Cells
rCell.Value = rCell.Value ^ 2
Next rCell

End Sub
'<<============

If you are not familiar with macros, you may wish to visit David McRitchie's
'Getting Started With Macros And User Defined Functions' at:

http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top