Solved

Excel 2010 Macro to Format Number to Remove the .0 at the End

Posted on 2016-07-19
4
49 Views
Last Modified: 2016-07-19
We have Excel 2010 and Access 2010.

I exported some data from my Access database into an Excel spreadsheet named Example.xls.  In column A I have reference numbers, but some of the numbers are formatted wrong and I need to change them.

I need to remove the .0 from the end of any number.  In my attachment, I have highlighted the numbers which need to be changed with code.  For example the number 2014800136156.0 needs to be changed to 2014800136156.

Can anyone provide me with the code to change these numbers in column A automatically through vba macro.

Thanks in advance.
Example.xls
0
Comment
Question by:Senniger1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41719489
Hi,

Pls try
    Columns("A:A").Replace What:=".0", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

    Columns("A:A").NumberFormat = "0"

Open in new window

Regards
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 41719499
Format the column as Text and then run this macro.

Sub RemoveZero()
Dim lngLastRow As Long
Dim lngRow As Long

lngLastRow = ActiveSheet.UsedRange.Rows.Count

For lngRow = 2 To lngLastRow
    If Right(Cells(lngRow, "A"), 2) = ".0" Then
        Cells(lngRow, "A") = Split(Cells(lngRow, "A"), ".")(0)
    End If
Next

End Sub

Open in new window

0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 41719502
Use Rgonzo1971's code. It's better and faster than mine.
0
 

Author Closing Comment

by:Senniger1
ID: 41719568
Perfect!
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question