+ Reply to Thread
Results 1 to 5 of 5

My code looks inefficient (but works)

  1. #1
    Registered User
    Join Date
    05-17-2011
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2007
    Posts
    9

    My code looks inefficient (but works)

    Hi All

    My code works, but looks really inefficient and I would welcome improvements.

    Part 1. This looks at each column in a range and records the cell value as a variable called "Mth(X)" where X is the column number. I'm okay with this part.

    Please Login or Register  to view this content.
    Part 2. This part should find the starting column (StartCol), then write out the 12 variables recorded in part 1, moving across the range two columns at a time. This seems inefficient, but I couldn't figure out how to LOOP through my variables.

    Please Login or Register  to view this content.
    Any help provided would be appreciated.

    Thanks in advance.

    Happy Hole

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: My code looks inefficient (but works)

    probably something like this
    Please Login or Register  to view this content.
    *untested

    you could probably shorten the code up even more to not have to use select but i am not sure what your code actually does and dont have the data to test
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

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

    Re: My code looks inefficient (but works)

    maybe
    Please Login or Register  to view this content.
    Josie

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

  4. #4
    Registered User
    Join Date
    05-17-2011
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: My code looks inefficient (but works)

    Hello

    Thanks to you both - I ended up with a solution that used a bit of each of your code and it's much shorter and efficient now. There's a lot of For/Next, Do/While and Do/Until loops in this routine and I'm quite the newbie with creating variables with loops, so it's great to get help to have this working. Makes me realise how wildly inefficient some my earlier stuff was.

    Thanks again.

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: My code looks inefficient (but works)

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Never use Merged Cells in Excel

+ 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. Inefficient code - macro takes too long
    By dantray02 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-07-2014, 09:29 AM
  2. [SOLVED] Very inefficient code because of different sizes of arrays, how do i shorten my code?
    By Brammer88 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-28-2012, 04:49 PM
  3. Improve working, but inefficient code
    By gnoke in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2012, 07:44 AM
  4. Inefficient code
    By T De Villiers in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2008, 02:10 PM
  5. inefficient code?
    By David in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2005, 06:06 AM

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