+ Reply to Thread
Results 1 to 2 of 2

Loop Through Rows in VBA to import into SQL

  1. #1
    Registered User
    Join Date
    09-18-2015
    Location
    london
    MS-Off Ver
    2010
    Posts
    18

    Loop Through Rows in VBA to import into SQL

    Hi,

    I am trying to import a table into SQL using VBA.

    What I want to do is loop through each row taking all the data then import this into SQL.

    I could define each column but using:

    Currentrow = 2

    term1 = sheet1.cells(currentrow, 2)
    term2 = sheet1.cells(currentrow, 3)
    term3 = sheet1.cells(currentrow, 4)

    Etc however I have 52 columns so was hoping there would be a smarter way of doing this.

    Attached is a sample of my work:

    sample7.xlsx

    Thank you for any help.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Loop Through Rows in VBA to import into SQL

    Here's a nice article about that.
    David
    (*) Reputation points appreciated.

+ 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. Help with Import function, loop?
    By Fredma in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2015, 12:09 PM
  2. [SOLVED] How to run Loop in VBA to import more than one file
    By zaska in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-29-2015, 02:15 PM
  3. Import data Transpose in VBA loop-Thank you!
    By esther723 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2013, 11:42 AM
  4. Need help to loop macro to import 100k rows per sheet until end.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2012, 02:07 AM
  5. Need help to loop macro to import 100k rows per sheet until end.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2012, 12:12 AM
  6. .txt import loop
    By Littleeleven in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-01-2011, 11:44 AM
  7. Do While Loop to Import Worksheets from Various Workbooks
    By kchm_2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-23-2011, 12:08 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