• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

remove decimals by vba

r@1234

Member
I will place the macro in a seperate file macro.xlsm
and i have a file name 1.xls
in 1.xls in column K i have data (i have attached the sample pic of that)
what i need is i need a macro that will remove third number after decimal and along with it it should remove the decimal
Result will be
1090.699 after runing the macro the ouput will be 109069
147.965 after runing the macro the ouput will be 14796
264.4785 after runing the macro the ouput will be 26447
30.2495 after runing the macro the ouput will be 3024

plz help me in solving this problem by vba
 

Attachments

  • 1.PNG
    1.PNG
    2.2 KB · Views: 16
Multiply the number by 100 then use the VBA function Fix …​
As the efficient way is a worksheet formula even under VBA.​
 
Bro i am unable write a code thats y i am looking for help can u let me know the code bcoz i know little about vba so plz help sir
 
I will use this macro on daily basis I dont need a formula sir bcoz everyday i cant put a formula
I hope u understand as per my needs vba is best for me so plz help me for the same sir
 
This is how Marc's suggestion would look. Adjust the range to suit

Code:
Public Sub AdjustRange()
Range("A1:A4").Value = Evaluate("INT(" & Range("A1:A4").Address(0, 0) & "*100)")
End Sub
 
Close to I was thinking according to an Excel beginner formula (done by a kid !) so converted to a VBA procedure​
the unique codeline necessary is [K2:K5] = [IF({1},INT(K2:K5*100))] according to the initial picture :rolleyes: …​
Do you like it ? So thanks to click on bottom right Like !​
 
Code:
Sub STEP8()
  Dim Wb1 As Workbook, Ws1 As Worksheet, Lr1 As Long
  Set Wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xls")
  Set Ws1 = Wb1.Worksheets.Item(1)
  Let Lr1 = Ws1.Range("H" & Ws1.Rows.Count).End(xlUp).Row
   Ws1.Range("K2:K" & Lr1 & "").Value = "= Evaluate("INT(" & Range("K2:K").Address(0, 0) & "*100)")"
   Ws1.Range("K2:K" & Lr1 & "").Value = Ws1.Range("K2:K" & Lr1 & "").Value
   Wb1.Save
   Wb1.Close
End Sub






i need vba code for this problem Sir i tried to make the vba code for the same i got error sir so plz help me in solving this problem Sir
 
Restart by well reading this time the syntax of post #6 (your error #1),
do not forget to well qualify the second range (your error #2) (or directly the entire address as the Address property is superfluous here) and​
your procedure needs only a .Value = codeline for the same range, the second is useless and​
as you use some useless / superfluous object variables do not forget to set them to Nothing at the end of the procedure …​
 
Bro plz correct my code & provide me the correct code ,so that i can understand my mistake ,i am unable to understand what u mean to say sir
 
Back
Top