+ Reply to Thread
Results 1 to 2 of 2

VBA Excel - SQL datbase search looping

  1. #1
    Registered User
    Join Date
    07-25-2014
    Location
    United Kingdom
    MS-Off Ver
    2013
    Posts
    1

    VBA Excel - SQL datbase search looping

    Hello,

    New to the forums so apologies if i am in the wrong place.

    Currently getting used to VBA inside excel and have been doing some tutorials and practices to get used to the code and have been trying to carry out a simple task without any success.

    My task is to compare a range of cells and inside each cell inside this range get the string/text and assign it to a variable. then use this variable in a SQL statement to query a small database and return the result.

    I have opted to do this with a for loop which gets the current cells text, assigns it to the variable and then executes the query and pops it into another cell, the problem is that outside out of the loop the code will run fine and i can change the name of the variable and everything is hunky dory, when inside the loop i get an error along the lines of

    "RUN-TIME ERROR '3705':
    Operation is not allowed when the object is open"

    Please Login or Register  to view this content.
    This is how i have written the code, ive looked in the forums here and on google for a solution but cant seem to find a similar case, the red text is to highlight were the debug always goes to.

    All helps is appriciated thank you
    Last edited by Jimjebus; 07-25-2014 at 06:50 AM. Reason: missed out information

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: VBA Excel - SQL datbase search looping

    Please Login or Register  to view this content.
    Also please read the forum rules on cross-posting.
    Remember what the dormouse said
    Feed your head

+ 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. Keyword Search -> Copy and Paste VBA Macro Issue
    By anonamouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2012, 07:46 PM
  2. looping a search function
    By pvo2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2008, 08:35 PM
  3. What driver to use to filter a datbase (.txt) on Notepad?
    By spenceless in forum Excel General
    Replies: 1
    Last Post: 08-04-2005, 01:05 PM
  4. Fantasy Football Datbase or Formula
    By Dave in forum Excel General
    Replies: 0
    Last Post: 07-08-2005, 05:05 PM
  5. [SOLVED] Datbase check
    By gunga in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-01-2005, 04:06 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