Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to create a macro and a button

  Asked By: Kaua    Date: Mar 20    Category: MS Office    Views: 913
  

I would like to create a button with a macro attached to it for
excel. I've found instructions on how to create the button and link a
macro to it but I need help creating the macro. What I would like the
button to do is return the absolute value of the number in that cell,
=ABS(). For example, I have a group of cells A1-E1 and when I
highlight them I would click the ABS button and it would change each
entry into it's ABS. Is this possible? I've never written any code
but I want to learn so any help is appreciated.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Dale Jones     Answered On: Mar 20

Try this:

Sub MakeAbs()
For Each c In Selection
c.Value = Abs(c.Value)
Next c
End Sub

 
Didn't find what you were looking for? Find more on How to create a macro and a button Or get search suggestion and latest updates.




Tagged: