Not tested, but not much to go wrong with this either
public function sqnum (num2bsquared as double) as double
sqnum=num2bsquared * num2bsquared
end function
Gene, "The Mortgage Man", Klein
This is a discussion on How to square a number in VBA excel? within the Excel Questions forums, part of the Question Forums category; Hi how to sqUARE A NO. IN vba EXCEL?...
Hi how to sqUARE A NO. IN vba EXCEL?
Not tested, but not much to go wrong with this either
public function sqnum (num2bsquared as double) as double
sqnum=num2bsquared * num2bsquared
end function
Gene, "The Mortgage Man", Klein
Gene, "The Mortgage Man", Klein
See all my Mishegas Videos
NEW: MY INTERNET RADIO SHOW:
http://www.blogtalkradio.com/mortgageman
we will need more information on what you are wanting to do,
like where do you get the number from that you are wanting to SQUARE and where do you want the result to be
the code using an input and a message box for the result would be#
HTHCode:Sub squre() x = 0 x = InputBox("enter number") z = x * x MsgBox ("the Squre of " & x & " is " & z) End Sub
Thanks Shippey
.. or perhaps something like this?
Sub Square()
****Selection.Offset(0, 1).Value = Selection.Value ^ 2
End Sub
Hope this helps, good luck.
Peter
- Read the Posting Guidelines, Forum Rules & FAQs
- Want to post a small screen shot? Try one of these Excel jeanie, MrExcel HTML Maker or Borders-Copy-Paste
- If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the VBHTML Maker
Bookmarks