+ Reply to Thread
Results 1 to 28 of 28

Optimize Excel Code - Too many FOR NEXT Loops

Hybrid View

  1. #1
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Optimize Excel Code - Too many FOR NEXT Loops

    This makes bit faster, however the problem is that you have too many cell formatting code.
        ReDim a(1 To UBound(a, 1) * 2, 1 To UBound(a, 2)): n = 0
        For Each e In dic
            For Each s In dic(e)
                w = dic(e)(s)
                For ii = 1 To UBound(w, 2)
                    n = n + 1
                    For i = 1 To UBound(w, 1) - 2
                        a(n, i) = w(i, ii)
                        If (a(n, i) >= sd) * (a(n, i) <= ed) Then
                            If x Is Nothing Then
                                Set x = Sheets("Aligned").Cells(n + 2, i)
                            Else
                                Set x = Union(x, Sheets("Aligned").Cells(n + 2, i))
                            End If
                        End If
                    Next
                Next
            Next
        Next
    Last edited by jindon; 10-22-2021 at 10:35 PM.

+ 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] Improve code performance to Optimize Loops
    By MusicMan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-19-2021, 01:07 PM
  2. How to Optimize This Code?
    By therealdees in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-20-2021, 02:40 AM
  3. Trying to optimize VBA code for Excel 365
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2019, 01:58 AM
  4. [SOLVED] Optimize my VBA code
    By modytrane in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-07-2019, 11:25 AM
  5. [SOLVED] optimize macro - cutting down loops and autofill
    By gwsampso in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-04-2012, 12:56 AM
  6. Optimize code
    By miso.dca in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-08-2011, 03:35 PM
  7. if else loops excel vba code required
    By razwan1978 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-09-2009, 03:10 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