Solved

Text Convert to Number

Posted on 2014-02-10
6
292 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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 80

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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 in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now