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

Data CurrentlyData needs to be
30003.0
1152011.520
9820.982
31003.1
72117.211
84008.4
41224.122

<tbody>
</tbody>


Cheers for your help again guys.

Luke
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

6StringJazzer

Well-known Member
Joined
Jan 27, 2010
Messages
714
Office Version
  1. 365
Platform
  1. Windows
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.
 

Lukums

Board Regular
Joined
Nov 23, 2015
Messages
195
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!
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,692
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
So everything in column "A" needs to stay in Column "A" ??....or a new column ??
 

Lukums

Board Regular
Joined
Nov 23, 2015
Messages
195

ADVERTISEMENT

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.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,216
Office Version
  1. 365
Platform
  1. Windows
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"
 

Fazza

MrExcel MVP
Joined
May 17, 2006
Messages
9,368
maybe something like
Code:
With Range("A1").CurrentRegion.Columns(1) 'change to suit
    .Value = Evaluate(.Address & "/1000")
    .NumberFormat = "#,##0.0"
End With
 

Watch MrExcel Video

Forum statistics

Threads
1,122,168
Messages
5,594,632
Members
413,919
Latest member
ZaxAlchemist

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
Top