Solved

Text Convert to Number

Posted on 2014-02-10
6
306 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
[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
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:Naresh Patel
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

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