Solved

Text Convert to Number

Posted on 2014-02-10
6
305 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

738 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