Solved

Text Convert to Number

Posted on 2014-02-10
6
302 Views
Last Modified: 2014-02-11
Hi Experts,

I need some help.  I have four columns that are sometimes text and sometimes number (columns J,k,l,m).   I would like a macro that checks to see if the column is text or a number and if it is text then convert it to a value.  

Thanks,
Montrof
0
Comment
Question by:montrof
6 Comments
 
LVL 23

Expert Comment

by:NBVC
ID: 39847711
All you need to do is enter a 0 in any empty cell and copy that cell.

Select your four columns, right-click, select Paste Special, then select Add from the Operation section, and then click Ok.

Now all "text" numbers should be real values.
0
 
LVL 1

Author Comment

by:montrof
ID: 39847879
I have a much more involved macro that imports a file and sometimes it is a number and sometimes it is text.  So I wanted to do this programmatically.
0
 
LVL 8

Expert Comment

by:itjockey
ID: 39848194
As Mr.NBVC  said do the same procedure while recording a macro.so next time you copy past data in that sheet.just run that macro.that it.or you can save that macro in personal library so in all workbook you can use that macro.

Thanks
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:montrof
ID: 39848214
I ended up writing a short macro that seems to work

Private Sub Con_Txt_Num()
    Dim rUsedRange As Range
    Worksheets("S").Select
    For Each rUsedRange In Columns("J:M")
        rUsedRange.Value = rUsedRange.Value
    Next rUsedRange
End Sub

Open in new window


Thanks,
Montrof
0
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39849180
You may find this tweak to your code runs faster--because it doesn't consider every cell in the columns:
Sub Con_Txt_Num()
Dim rUsedRange As Range
Application.ScreenUpdating = False
With Worksheets("S")
    Intersect(.Range("J:M"), .UsedRange).Value = Intersect(.Range("J:M"), .UsedRange).Value
End With
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:montrof
ID: 39849971
Thanks for the help.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
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…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

821 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