+ Reply to Thread
Results 1 to 8 of 8

Convert text to number in different columns across three worksheets via macro?

  1. #1
    Registered User
    Join Date
    12-29-2010
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Question Convert text to number in different columns across three worksheets via macro?

    Hi! Hoping you can help a newbie macro padawan here.

    I have three sheets in one file. Each sheet has some number columns that come through as text and need to be converted to number. Bu the location of the columns is different on each sheet.

    So I basically want to tell it go to the sheet called "Summary" and convert columns O through Q to number. Then go to the sheet called "Invoice Detail" and convert columns A & B to number. etc..

    I cobbled together this bit of code. But it's not doing it for all three sheets, only one. Could someone tell me where I am going wring? Many thanks.


    Please Login or Register  to view this content.
    Update - I did a step through debug. It's converting the first section just fine. Then on the next two it seems to get the selection right, but when it gets to the line converting the numbers it seems to lose the selection and not actually convert anything. Ugh, it has to be just staring me in the face. Thanks!
    Last edited by poetstorm; 05-30-2019 at 08:32 PM.

  2. #2
    Registered User
    Join Date
    12-29-2010
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Convert text to number in different columns across three worksheets via macro?

    Thanks for the reminder. It has been a while. Done.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Convert text to number in different columns across three worksheets via macro?

    Did you try setting the range AFTER you Select the sheet ?

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,552

    Re: Convert text to number in different columns across three worksheets via macro?

    No need to Select/Activate.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-29-2010
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Convert text to number in different columns across three worksheets via macro?

    Quote Originally Posted by bakerman2 View Post
    Did you try setting the range AFTER you Select the sheet ?

    Please Login or Register  to view this content.
    That worked! I kinda had a feeling that was putting the cart before the horse, but that's how I saw the code online. Should have trusted my gut on that. Thank you so much!

  6. #6
    Registered User
    Join Date
    12-29-2010
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Convert text to number in different columns across three worksheets via macro?

    Quote Originally Posted by jindon View Post
    No need to Select/Activate.
    Please Login or Register  to view this content.
    Ooh, that is an interesting way to do it. I haven't really learned arrays yet but I like how this is written. I'm going to hold on to this for future.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,552

    Re: Convert text to number in different columns across three worksheets via macro?

    poetstorm,

    Your code is selecting entire column(s) and changing the cell format.
    That make the file unnecessarily big.

  8. #8
    Registered User
    Join Date
    12-29-2010
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Convert text to number in different columns across three worksheets via macro?

    Yep. I have noticed that actually with a lot of the macros I create, but I don't know how to tell the macro to only go down to filled out cells, and the row length on my files varies wildly. Still learning. I may try to use your code instead if that solves the issue.

    Thanks everyone!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Excel Macro to Convert Number Format into 'Comma Style' accross All Worksheets
    By arnel_10 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-09-2017, 05:01 AM
  2. [SOLVED] Macro to convert text number to digital number
    By Patish in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2014, 07:43 AM
  3. [SOLVED] VBA Macro to convert text to number
    By Pho6 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-13-2013, 02:04 AM
  4. Macro to convert text to number
    By Wgmoneill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2012, 02:12 PM
  5. Macro to copy selected columns, convert to number and paste to new tab
    By Greed in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-06-2011, 06:11 PM
  6. Convert a number formatted as text to a number in a macro
    By MACRE0 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2005, 09:51 PM
  7. Macro for Text to Columns - convert to text or general
    By goofy11 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2005, 11:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1