Solved

Select Range and Convert Text to Numbers in Excel VBA

Posted on 2013-01-22
2
421 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
[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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

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