+ Reply to Thread
Results 1 to 9 of 9

My formatting code takes forever - please enhance?

  1. #1
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    My formatting code takes forever - please enhance?

    This code simply formats my sheet but it takes forever and a day to finish the job....is there a more effective way to write this?

    (a lot of it has been taken from recording macros and using that code)

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: My formatting code takes forever - please enhance?

    Not sure if it would make much difference, depends how big your named ranges are but you can change your loops such as:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: My formatting code takes forever - please enhance?

    that has sped it up a bit,

    how do you change my loop to match your code

    Please Login or Register  to view this content.
    My attempt

    Please Login or Register  to view this content.
    doesnt work...(type mismatch error)

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: My formatting code takes forever - please enhance?

    Ah, I guess you can't use it with the UCase function.

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: My formatting code takes forever - please enhance?

    if Account,AccountAPRP and Comment are not contiguous, using Application.proper(Range("Account,AccountAPRP,Comment").value) will convert them all to the values in the first range
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: My formatting code takes forever - please enhance?

    JosephP

    thanks you have just solved my brain scratcher, I didnt understand why that was happening!!!

    have to revert back to my original (but very slow) code from the first post......any other ideas?

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: My formatting code takes forever - please enhance?

    you can loop the areas
    Please Login or Register  to view this content.
    for ucase you can't do that (and application.upper doesn't exist) so you would be better off using arrays
    Please Login or Register  to view this content.
    for instance

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: My formatting code takes forever - please enhance?

    untested of course but perhaps
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: My formatting code takes forever - please enhance?

    Wow, you have reduced my macro running time from 25 seconds to 1 second!! Legend!

    have some rep!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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