Results 1 to 10 of 11

Thread: Make Text to Numbers Code More User Friendly

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member mrmmickle1's Avatar
    Join Date
    Sep 2012
    Posts
    51
    Rep Power
    14
    Rick,

    You are incredible. THanks so much for your efforts. I sampled the code and it of course works perfectly for my purposes. I was wondering... I have no purpose to speed this macro up but, just for good practice. If I wanted the same end result is it feasible to delete this portion of code?
    Code:
      Col.NumberFormat = "General"
    Using Excel 2010

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by mrmmickle1 View Post
    Rick,

    You are incredible. THanks so much for your efforts. I sampled the code and it of course works perfectly for my purposes. I was wondering... I have no purpose to speed this macro up but, just for good practice. If I wanted the same end result is it feasible to delete this portion of code?
    Code:
      Col.NumberFormat = "General"
    Yes, you can remove that line... it is left over from a previous test. You might want to consider using snb's code instead, though... besides being more compact, it also includes an error handler as well (although I like to turn the error handler off afterwards by putting an
    Code:
    On Error GoTo 0
    statement at the end).
    Last edited by Rick Rothstein; 11-18-2012 at 11:02 PM.

  3. #3
    Member mrmmickle1's Avatar
    Join Date
    Sep 2012
    Posts
    51
    Rep Power
    14
    Snb/Rick,

    Thank you both. I appreciate your time. The final product I am using looks like this:

    Code:
      Sub FormatTexttoNumbers()
        Dim Col As Range
        On Error Resume Next
        Set Col = Application.InputBox("Please select a column...", Type:=8)
        Set Col = Columns(Col.Cells(1).Column)
        Col.NumberFormat = "0.00"
        Col.Value = Col.Value
      On Error GoTo 0
    End Sub
    I tried to use Snb's code for a shorter solution but it didn't seem to change the format, it seemed to be the same problem as before. The formatting wasn't changing. Does this look like a good solution? I am unfamiliar with error handling. I have only used it in one macro I have written. Is it considered proper to put the error statement below the Dims or should it come before all statements at the beginning of the macro?
    Using Excel 2010

Similar Threads

  1. Remove Special Characters From Text Or Remove Numbers From Text
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 5
    Last Post: 05-31-2013, 04:43 PM
  2. Replies: 14
    Last Post: 05-25-2013, 06:55 AM
  3. Replies: 2
    Last Post: 05-13-2013, 12:03 AM
  4. Replies: 3
    Last Post: 04-05-2013, 08:24 AM
  5. tracking changes and prompt user
    By princ_wns in forum Excel Help
    Replies: 1
    Last Post: 01-22-2012, 03:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •