Solved

Select Range and Convert Text to Numbers in Excel VBA

Posted on 2013-01-22
2
395 Views
Last Modified: 2013-01-23
1) I need to select cells from H3 to Mxxx where total rows are variable and unknown

2) I need to convert those values from Text to Number

I found this much code and it works for any selection that I manually highlight.  But I'm having trouble with number #1.

    '   Check to see if selection is formatted as Text -
    '   If so, then reformat selection as General
    '**********************************************************
    If Selection.NumberFormat = "@" Then _
            Selection.NumberFormat = "General"
           
    '   Replace formulas and numeric strings with real numbers
    '**********************************************************
    Selection.Value = Selection.Value
0
Comment
Question by:newknew
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 38807901
To apply to the last populated cell in Col M...


Dim LastR As Long

With ActiveSheet
    LastR = .Cells(.Rows.Count, "m").End(xlUp).Row
    With .Range("h3:m" & LastR)
        .NumberFormat = General
        .Value = .Value
    End With
End With

Open in new window

0
 
LVL 1

Author Closing Comment

by:newknew
ID: 38810763
worked perfectly, thank you!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvieā€¦
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

808 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