+ Reply to Thread
Results 1 to 2 of 2

The code takes ages to respond. Why?

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    The code takes ages to respond. Why?

    Hi All

    Is there any problem in the code?? When I run it then continue running and doesn't stop. WHy?/
    [code]
    lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
    For i = 2 To lastrow
    strsql = "select * from Jabberwocky where Batchno=" & ws.Cells(i, 1).Value & ""
    rs.Open strsql, cn

    If Not (rs.BOF = True And rs.EOF = True) Then
    ws.Cells(i, 2).Value = rs.Fields("Policyno").Value
    End If
    rs.Close
    Next i
    [code]

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

    Re: The code takes ages to respond. Why?

    How many rows is it looping through? Have you tried stepping through the code (F8), to see how long the query is taking for each row?
    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...

+ 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. It takes 1-2 minutes to respond when changing a value of cell
    By jayce_sos in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2014, 03:00 AM
  2. Replies: 2
    Last Post: 12-07-2010, 10:14 AM
  3. Loading Excel - please help - takes ages to load
    By Smilersal in forum Excel General
    Replies: 0
    Last Post: 07-12-2006, 09:15 AM
  4. loading excel takes ages
    By Smilersal in forum Excel General
    Replies: 3
    Last Post: 07-11-2006, 01:35 PM
  5. exiting excel takes ages if any add-in loaded
    By Robin Hammond in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-06-2005, 06:05 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