ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Writing a Macro to add decimal (https://www.excelbanter.com/excel-worksheet-functions/43582-writing-macro-add-decimal.html)

CindyW

Writing a Macro to add decimal
 
I need to add a decimal to each number in a column of figures. For examples
7254
6523
8945
12546

I need to put a decimal point where the "thousands" would begin.
e.g:
7254 - 7.254

I want to write a macro that will go to the end of each figure, go back
three spaces and put a decimal there. Is this possible? How do I do it?
HELP!!!!!!!

Ken Wright

You don't, you simply put 1000 in an empty cell, copy that cell, select all
your data and do edit / paste special / divide, and then delete the 1000.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

------------------------------*------------------------------*----------------
It's easier to beg forgiveness than ask permission :-)
------------------------------*------------------------------*----------------


"CindyW" wrote in message
...
I need to add a decimal to each number in a column of figures. For
examples
7254
6523
8945
12546

I need to put a decimal point where the "thousands" would begin.
e.g:
7254 - 7.254

I want to write a macro that will go to the end of each figure, go back
three spaces and put a decimal there. Is this possible? How do I do it?
HELP!!!!!!!




Duke Carey

Does it have to be a macro?

You can put .001 into an empty cell, copy it, select all the numbers, and use
Edit-Paste Speical-Values-Multiply



If they

"CindyW" wrote:

I need to add a decimal to each number in a column of figures. For examples
7254
6523
8945
12546

I need to put a decimal point where the "thousands" would begin.
e.g:
7254 - 7.254

I want to write a macro that will go to the end of each figure, go back
three spaces and put a decimal there. Is this possible? How do I do it?
HELP!!!!!!!


dominicb


Good evening CindyW

Something like this would do it. It doesn't actually count back three
digits from the end, but divides the number by 1000 - the end result
should be the same. Just remember to highlght the ange you want to
affect before running it.

Sub Thousands()
For Each num In Selection
num.Formula = num.Formula / 1000
Next num
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=401295



All times are GMT +1. The time now is 04:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com