+ Reply to Thread
Results 1 to 10 of 10

Wondering if theres a more efficient way besides For Each to...

  1. #1
    Forum Contributor
    Join Date
    10-30-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    100

    Wondering if theres a more efficient way besides For Each to...

    I have code for an invoice to make the line bigger if there is a quantity and small if it is blank. Looks like this:

    Please Login or Register  to view this content.
    I'm just wondering if someone knows a more efficient way to accomplish this without using 'For Each' process. It just seems like it takes time to process each line and there might be a quicker way to do this.

    Any ideas experts?

    Thanks
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    06-25-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Wondering if theres a more efficient way besides For Each to...

    Hi Tricky, Try this formula without using your code

    =IF(D18>=1,"---------","----")
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    10-30-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: Wondering if theres a more efficient way besides For Each to...

    mmm... that does nothing.. I think you misunderstood the post?

    When you input values to the qty column the ROW gets bigger by the font size and bold's it, and sets the font size to small not bold when qty is empty.

    It accomplishes this with the 'for each' procedure and I am wondering if there is a faster more efficient method.
    Last edited by trickyricky; 06-27-2012 at 03:58 PM.

  4. #4
    Registered User
    Join Date
    06-25-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Wondering if theres a more efficient way besides For Each to...

    Please say thanks to the members (this is one of the forum rule) for spent their valuable time to help you on giving the solution, whether it is right or not.

  5. #5
    Forum Contributor
    Join Date
    10-30-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: Wondering if theres a more efficient way besides For Each to...

    Oh I'm so sorry I didn't know you were done discussing this thread with me! THANK YOU FOR YOUR MOST VALUABLE TIME I APPRECIATE EVERY TEENY BIT OF IT!!
    Sorry you didn't understand what I was asking!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wondering if theres a more efficient way besides For Each to...

    Hello trickyricky,

    You can improve the speed of the macro by applying the changes to groups of cells simultaneously. When a range is non contiguous, the cells are grouped together when possible, to form an Area. If there is only one cell or the range is contiguous, there is only Area. By exploiting this property and the ability to change an entire range at once, your speed increases significantly. Here is the revised code.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  7. #7
    Forum Contributor
    Join Date
    10-30-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: Wondering if theres a more efficient way besides For Each to...

    Leith I see what you're saying and it makes perfect sense. However I've tried the new code you suggested and it doesn't seem to be working the same way anymore. For instance when I delete quantities, the line should reduce font size and remove bold, however the line's font size and bold isn't changing. Can you spot anything wrong in the code?

    One thing I did notice was the part where you
    'Extend cell to include columns "D:L"
    should say
    Please Login or Register  to view this content.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wondering if theres a more efficient way besides For Each to...

    Hello trickyricky,

    Can you post a copy of the workbook for review?

  9. #9
    Forum Contributor
    Join Date
    10-30-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: Wondering if theres a more efficient way besides For Each to...

    Here is the file:
    Attached Files Attached Files

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wondering if theres a more efficient way besides For Each to...

    Hello trickyricky,

    Thanks for posting the workbook. I have the macro working. Here is the updated code.
    Please Login or Register  to view this content.

+ 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