Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

Text Convert to Number

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
montrof
Asked:
montrof
1 Solution
 
NBVCCommented:
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
 
montrofAuthor Commented:
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
 
Naresh PatelTraderCommented:
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
Industry Leaders: 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!

 
montrofAuthor Commented:
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
 
byundtCommented:
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
 
montrofAuthor Commented:
Thanks for the help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now