Macro to double values in a cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a worksheet with values in one column. I need to go back to some of
those values and in the same cell, double them. Can anyone please help me
with a macro to do that? I tried it but when I run the macro I get the same
value as the one in the cell where the macro was made. I realise this has to
do with absolute and constant values but am not competent enough to correct
my macro.

Any help will be very appreciated. Many thanks

M Shroff
Canada
 
Give this a go.

Select the cells you want to double and run this macro.

Sub DoubleIt()
Dim cell As Range
For Each cell In Selection
cell.Value = cell.Value + cell.Value
Next
End Sub

HTH
Regards,
Howard
 
Im kind of wondering what you mean by "Some of those Values"?

Because if you just want to create a Key Shortcut... start up a Macro and
input the code...

ActiveCell.Formula = ActiveCell.Value * 2

This way you can click on the cell you want to multiply by two and either
run the macro or use the keyboard shortcut you created.

If you want to double all the values or theres a certain criteria you need
to meet in order to double the values, I will have to know what it is to
write up the code... but its very possible.
 
Thank u AKphidelt. But you will have to bear with me (I am a total beginner)
when I ask where do I input the code? When I create a macro, I create a
short cut key and then perform the keystrokes to record the macro.

Thank you
M Shroff
 
Alright do this...

Go to Tools---> Macro---> Visual Basic Editor

In the Visual Basic Editor

Go to Insert---> Module

Then copy and paste this formula

Sub DoubleVal()
ActiveCell.Formula = ActiveCell.Value * 2
End Sub

Then go back to your Excel Spreadsheet

Go to Tools---> Macro---> Macros (w/ little green play button)

Then click on the Macro and go to Options
There you can place your keyboard shortcut

Let me know if this helps
 
YOU ARE A GOD-SEND. It worked. It has saved me hours of work.

Many many thanks
M Shroff
 
Thank u for taking the time to reply. I used the other tip and it worked.
"Phew" saved me lots of work.

Appreciate your input
M Shroff
 
Maybe a selection change event macro would have been a good idea.

Biff
 
Maybe a selection change event macro would have been a good idea.

Or not, now that I think about it a little more!

Biff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top