+ Reply to Thread
Results 1 to 9 of 9

Macro to extract numbers freezes excel

  1. #1
    Registered User
    Join Date
    02-07-2013
    Location
    mtamrb escaped
    MS-Off Ver
    excel 2010
    Posts
    6

    Question Macro to extract numbers freezes excel

    Standard disclaimer: I'm not a VBA regular. I rarely work with Excel so most of my code is gleaned from more qualified folks, hopefully like you.

    I'm writing a macro (or a series of them which I'll combine later) to calculate a due date based on invoice date and terms (expressed as NET10). Everything is running well except this critical part of extracting the numerical value. This code is beyond me once it gets to the InputBox which I'd be happy to replace with a selection of a specific column since it will always be the same one.

    It works... eventually. When running this macro excel goes into a (not responding) state for a period of several minutes before pushing out the results. The results are correct but I can't explain why it struggles, my cpu doesn't exceed 20% so it's not lack of processor power.

    So my question is twofold:
    Can this be written in a way that doesn't bog down excel?
    and
    Is it possible to replace the selection with an assigned selection like something that is working in other sections: Range("D1:D" & LastRow)
    (yes, I would have to declare LastRow Variable)

    Please Login or Register  to view this content.
    while I have the floor, one more question:
    Is it better to write multiple macros and call them in a single one or actually write them as one?

    Thanks for this forum helping get me this far.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to extract numbers freezes excel

    Multiple macros are better because there will be less script to debug - the prevailing opinion.

    (Can't help with the regular expressions)
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    02-07-2013
    Location
    mtamrb escaped
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: Macro to extract numbers freezes excel

    Thanks for confirming my instinct.

    I don't even like regex in php, the lag is really annoying but eliminating the InputBox will make this a lot better on the end user.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro to extract numbers freezes excel

    You're not selecting entire columns, are you?
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    02-07-2013
    Location
    mtamrb escaped
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: Macro to extract numbers freezes excel

    Quote Originally Posted by shg View Post
    You're not selecting entire columns, are you?
    Well that explains why it takes so long...

    That means the more important question is how can I select only to the last row without using an InputBox?
    If nothing else, you have proven once again that my biggest problems are never what they seem.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro to extract numbers freezes excel

    Multiple Macros are easier to debug.

    You can step through your main macro and stepover the subroutines. The subroutines are completed without stopping.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro to extract numbers freezes excel

    how can I select only to the last row
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-07-2013
    Location
    mtamrb escaped
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: Macro to extract numbers freezes excel

    Thanks shg but it didn't take long to realize I'm not nearly well versed enough to put that into context.

    If, using the GetNumbers() function as I posted, how would this replace the selection step considering I need to select the contents of column E?
    And that without selecting the entire column of cells as you pointed out.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro to extract numbers freezes excel

    Replace
    Please Login or Register  to view this content.
    with that.

+ 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. Excel Freezes During Print Macro
    By dboatman_z in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2015, 01:11 PM
  2. excel freezes after updating cells and runing macro
    By sfcleon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-08-2013, 03:06 PM
  3. [SOLVED] Macro to extract numbers over 6 digets in column
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-25-2013, 05:46 AM
  4. [SOLVED] macro to extract 9 digit numbers as well as alpha numberic 9 digit numbers from txt file
    By Raju Radhakrishnan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2012, 10:15 AM
  5. Looping Macro Freezes Excel When Encountering Large Numbers of Rows
    By instant000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-16-2009, 01:17 PM
  6. Simple macro (ClearContent) freezes Excel
    By bokodilaszlo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2006, 09:24 AM
  7. Macro freezes up Excel
    By Jon Delano in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2005, 03:05 PM

Tags for this Thread

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