Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9104635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:54:48+00:00 2026-06-17T01:54:48+00:00

Issue: I’m having to search a large sheet for specific policy numbers. The find

  • 0

Issue: I’m having to search a large sheet for specific policy numbers. The find function takes quite a while when there are nearly 75,000 rows. Any suggestions on how to compare these two sheets of 75,000 rows? A solution i thought might work would be to sort each sheet and then take the policy number needed to be found and compare it to the middle row. Is there a way to compare that policy number and see if in the simple sort function it would be greater or less than? After finding that comparison, i would reset the upper and lower bounds and find the middle again. …Would this be quicker? Are there any other suggestions?

Thank you

Current Code:

Sub policyComment()

Dim x As Integer
Dim endRow As Variant
Dim polSer As String
Dim foundVal As String
Dim commentVar As Variant        

Windows("SuspenseNoteMacro.xlsm").Activate
Sheets("Main").Select

Range("A2").Select
endRow = ActiveCell.End(xlDown)

x = 2

Do
    polSer = Range("A" + CStr(x)).Value

    Windows("010713 Suspense ALL.xlsm").Activate
    Sheets("Sheet1").Select

    Set foundRange = Sheets("Sheet1").Cells.Find(what:=polSer, LookIn:=xlFormulas, lookat:=xlWhole)

   'foundRange = ActiveCell.Value     
    If foundRange Is Nothing Then
        Windows("SuspenseNoteMacro.xlsm").Activate
        Sheets("Main").Select
        Range("J" + CStr(x)).Value = "Not Found"
    ElseIf foundRange <> "" Then
        Sheets("Sheet1").Cells.Find(what:=polSer, LookIn:=xlFormulas, lookat:=xlWhole).Activate
        commentVar = Range("J" + CStr(ActiveCell.Row)).Value
        Windows("SuspenseNoteMacro.xlsm").Activate
        Sheets("Main").Select
        Range("J" + CStr(x)).Value = commentVar
    End If

    x = x + 1
    Range("A" + CStr(x)).Select
    foundRange = ""
Loop Until (x = endRow)

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:54:49+00:00Added an answer on June 17, 2026 at 1:54 am

    Your code is slow for a few reasons, but mainly because of how you are looping through each cell individually (the actual Find function is not what is slowing it down).

    Below, I’ve put your search column into an array and looped through that, which will be much, much faster. I’ve also taken out all your select and activate statements, as they are extraneous 99% of the time in VBA, and can also slow down your code a bit. Lastly, I turned off ScreenUpdating which helps as well.

    If I missed something in the refactoring, let me know.

    Option Explicit
    
    Sub policyComment()
    
    Dim x As Long, endRow As Long, polSer As String, foundRange As range, commentVar As String
    Dim varArr() As Variant
    Dim wksMain As Worksheet, wks1 As Worksheet
    
    Set wksMain = Sheets("Main")
    Set wks1 = Sheets("Sheet1")
    
    Application.ScreenUpdating = False
    
    With wksMain
    
        endRow = .range("A" & .Rows.Count).End(xlUp).Row
        varArr = .range("A2:A" & endRow)
    
        For x = LBound(varArr) To UBound(varArr)
    
            polSer = varArr(x, 1)
    
            With wks1
    
                Set foundRange = .Cells.Find(polSer, LookIn:=xlFormulas, lookat:=xlWhole)
    
                If foundRange Is Nothing Then
    
                    wksMain.range("J" & x + 1).Value = "Not Found" 'need to add 1 to x because arrays are zero based
    
                Else
    
                    commentVar = .range("J" & foundRange.Row)
                    wksMain.range("J" & x + 1).Value = commentVar ''need to add 1 to x because arrays are zero based
    
                End If
    
            End With
    
        Next
    
    End With
    
    Application.ScreenUpdating = True
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ISSUE Large dataset with many improperly or non-uniformly entered dates in a specific field.
issue facing while loading the messages in to mq channel, recieving an error like
Issue summary Changing the orientation of an iPad device or simulator while playing a
Issue: While working in Chrome, script not waiting for the Synchronous xhr response. Working
Issue I'm having is returning some data in a sidebar depending on which category
Issue I have recently found myself working with a large, unfamiliar, multi-department, C++ codebase
The Issue: I am having trouble installing wxPython on Ubuntu 12.04. I would like
ISSUE I am trying to convert a 8 digit number into a date while
Issue: I am calling a function on scroll in my code: $(window).bind('scroll',function (){ loading();
Issue: RODBC (falsely) returning zero rows Situation: I'm using RODBC to connect to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.