Moving a decimal VBA

Lukums

Board Regular
Joined
Nov 23, 2015
Messages
195
G'day guys.

Need to do a tricky one...

I'm not sure how this can be done with a VBA sub routine. Once the data shifts to another sheet ("DATA Currently") I need to run a VBA script afterwards to convert it into the "Data needs to be" values.

Anyone got ideas? I'm sure there would be a way

[TABLE="width: 500"]
<tbody>[TR]
[TD]Data Currently[/TD]
[TD]Data needs to be[/TD]
[/TR]
[TR]
[TD]3000[/TD]
[TD]3.0[/TD]
[/TR]
[TR]
[TD]11520[/TD]
[TD]11.520[/TD]
[/TR]
[TR]
[TD]982[/TD]
[TD]0.982[/TD]
[/TR]
[TR]
[TD]3100[/TD]
[TD]3.1[/TD]
[/TR]
[TR]
[TD]7211[/TD]
[TD]7.211[/TD]
[/TR]
[TR]
[TD]8400[/TD]
[TD]8.4[/TD]
[/TR]
[TR]
[TD]4122[/TD]
[TD]4.122[/TD]
[/TR]
</tbody>[/TABLE]


Cheers for your help again guys.

Luke
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
How does the data "shift to another sheet"? What range does it come from, what range does it go to, is it copied or moved, and how do you do it?

How much of this process is manual and how much do you want in VBA?

Shifting the decimal point is trivial; you just divide by 1000.
 
Upvote 0
How does the data "shift to another sheet"? What range does it come from, what range does it go to, is it copied or moved, and how do you do it?

How much of this process is manual and how much do you want in VBA?

Shifting the decimal point is trivial; you just divide by 1000.

Hey mate,

All the shifting - ranges is all done (that stuff is sorted).

The data is all copied into for example: Sheet1 Starting in A1 Column. What I want to do in VBA is look at "A" and then do the /1000 and somehow handle the 3000/4000/5000 values to 5.0 (with a decimal) not just a 3/4/5 outcome.

It's not trivial as /1000 won't give you 3.0 it will give you 3 unless I'm missing something here. For the majority 100% it works fine.
But for the 3000/4000/5000 etc is the issue mainly.

Appreciate the help!
 
Upvote 0
So everything in column "A" needs to stay in Column "A" ??....or a new column ??
 
Upvote 0
So everything in column "A" needs to stay in Column "A" ??....or a new column ??

Same column is fine. But if a helper column is required that's fine too.

For exmaple: This works...

If Sheets("Sheet1").Range("B1").Value = 3 Then

Sheets("Sheet1").Range("B1").Select

Selection.NumberFormat = "0.0"

So that said I think all I need is to sift through i to LASTROW to find these types of values and then decimal place backwards.
 
Upvote 0
You can put 1000 in a spare cell, copy it and then do a paste special with xlOperation
Code:
With Cells(1, Columns.Count)
    .Value = 1000
    .Copy
    .Range("A1:A1000").PasteSpecial xlOperation:=xlPasteSpecialOperationDivide
    .EntireColumn.Delete
End With

.Range("A1:A1000").NumberFormat = "0.0"
 
Upvote 0
maybe something like
Code:
With Range("A1").CurrentRegion.Columns(1) 'change to suit
    .Value = Evaluate(.Address & "/1000")
    .NumberFormat = "#,##0.0"
End With
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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