+ Reply to Thread
Results 1 to 6 of 6

Help Needed Changing Inefficient Code into Loops

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Vermont, Dakota
    MS-Off Ver
    Excel 2007
    Posts
    22

    Talking Help Needed Changing Inefficient Code into Loops

    Hi I'm still new to VBA but I've learned a lot. In a huge project I'm working on I have a ton of blocks that look like

    Please Login or Register  to view this content.
    There are cases for 7 and 8 that follow the same pattern. There is nothing beyond 9.

    I'd love to turn these into smaller footprint loops. Can anyone show me how to turn the above into a working loop? From there I feel as if I could apply it all over the place, I just would love to see an example that works to start in a context I'm familiar with.

    Thanks so much!

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Help Needed Changing Inefficient Code into Loops

    Here is one approach. I've only done the first coupe of lines but I hope you can see the logic for the rest.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-25-2013
    Location
    Vermont, Dakota
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Help Needed Changing Inefficient Code into Loops

    ill try and implement and see how it goes! thanks for the time and help

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Help Needed Changing Inefficient Code into Loops

    OK so ignore previous code - which is wrong -you might be able to add another loop and reduce the whole thing to this:
    Please Login or Register  to view this content.
    Last edited by StephenR; 11-12-2013 at 11:56 AM.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Help Needed Changing Inefficient Code into Loops

    Adding in the columns as well as the rows, adjusting the size of row hiding depending on target value, and making sure everything gets unhidden as well as hidden, we end up with:

    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Help Needed Changing Inefficient Code into Loops

    Perhaps this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ 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] 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
  2. Improve working, but inefficient code
    By gnoke in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2012, 07:44 AM
  3. Inefficient code
    By T De Villiers in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2008, 02:10 PM
  4. [SOLVED] inefficient code?
    By David in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2005, 06:06 AM
  5. VBA (Optimization) Help to replace inefficient Do .. Loops ...
    By Philip in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2005, 09:06 AM

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