Excel macro for converting numbers to values in thousands

monish_rk

New Member
Joined
Jul 15, 2009
Messages
7
Dear friends

I am looking for a macro which would convert a copied range of cells into thousands (in values) in another sheet. I frequently copy and paste values, and then perform a pastespecial function by dividing by 1000. I tried to record a macro to do this, but to no avail.

May I request your assistance in this.

The code that I recorded is as follows, but it does not run appropriately.

Thanks in advance

Regards
monish_rk

Code:
Sub Macro1()
'
' Macro1 Macro
'
'
'
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Selection.FormulaR1C1 = "=R[-3]C/1000"
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
This macro will paste the values of what you have copied, and then divide each cell by 1000

Code:
Sub PasteSpecial1000s()
Dim Qcell As Range

'Paste the values
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

'Loop through each cell and ddivide it by 1000
For Each Qcell In Selection
Qcell.Value = Qcell.Value / 100
Next Qcell

End Sub
 
Upvote 0
Dear ketsat

Thanks for your assitance. I tried the macro and noted that there was an error while running the same. VB indicated that the following portion of the code was not running properly.

Code:
'Paste the values
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False

When I ran the other piece of the code, it ran very well. I am wondering if you can still help.

Thanks.
 
Upvote 0
Hmm, it works fine for me on Excel07.
I can try it on Excel03, when I get to work.

What error are you getting?
 
Upvote 0
Dear ketsat

Thanks for your assitance. I tried the macro and noted that there was an error while running the same. VB indicated that the following portion of the code was not running properly.

Code:
'Paste the values
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False

When I ran the other piece of the code, it ran very well. I am wondering if you can still help.

Thanks.

The code provided by ketsat requires that you already are on the copy mode and have selected/copied the destination range before you run it.
 
Upvote 0
From what I read

Rich (BB code):
Sub Macro1()
'..Put 1000 in a cell and copy it
With Range("E1")
    .Value = 1000
    .Copy
End With
'..Now apply pastespecial with values and divide, you will need to adjust all ranges
Range("A1:D1000").PasteSpecial Paste:=xlPasteValues, Operation:=xlDivide
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,511
Messages
6,125,247
Members
449,217
Latest member
Trystel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top