+ Reply to Thread
Results 1 to 2 of 2

Speeding up a macro that looks for pair of values in long range

  1. #1
    Registered User
    Join Date
    11-09-2016
    Location
    GB
    MS-Off Ver
    Excel 2010
    Posts
    1

    Unhappy Speeding up a macro that looks for pair of values in long range

    Hi,

    I am struggling with one of the macros I have put together.

    In general for each cell in column Y I need to check if there is at least one row in the spreadsheet where value in column A is the same as value in column A in the row where the cell is, and the value in column J is "yes".

    I have adjusted some code I have came across online and it seems that it is working for short ranges. Unfortunately I have more than 100000 rows in the spreadsheet and this is just killing the macro.

    Pasting the code below. Could you please advise me how can I make it more efficient?


    Sub Macro1()

    On Error Resume Next


    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    Application.DisplayStatusBar = False
    Application.EnableEvents = False


    Dim rng As Range, cell As Range
    Dim FindString As String
    Dim rng2 As Range
    Dim count As Long
    Dim myRow As Range

    Set rng = Sheets("Sheet1").Range("Y2:Y100000")

    For Each cell In rng
    count = 0
    FindString = cell.Offset(0, -24).Value

    For Each myRow In Range("A2:X100000").Rows

    If myRow.Cells(1, 10).Value = "yes" And myRow.Cells(1, 1).Value = FindString Then

    count = count + 1

    End If

    If count > 0 Then Exit For

    Next myRow

    If count > 0 Then
    cell.Value = "yes"
    Else
    cell.Value = "no"

    End If

    Next cell

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    Application.DisplayStatusBar = True
    Application.EnableEvents = True


    End Sub

    Thank you in advance!

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Speeding up a macro that looks for pair of values in long range

    Maybe :
    Please Login or Register  to view this content.
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

+ 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. Copy range into every 2nd of a pair of blank rows.
    By and351 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2015, 11:02 AM
  2. Replies: 6
    Last Post: 02-04-2014, 12:27 PM
  3. Target range in macro is too long?
    By theskeptic99 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2013, 10:36 PM
  4. [SOLVED] Help in speeding up my macro!
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2013, 12:04 PM
  5. Help speeding up matching a list of values over multiple workbooks
    By wizuriel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2013, 12:09 PM
  6. [SOLVED] Speeding up Macro that Hides Rows when Range ("B178:B477") contains a zero value
    By SoteriaLive in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 09-26-2012, 04:02 PM
  7. Replies: 2
    Last Post: 01-15-2006, 05:10 PM

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