+ Reply to Thread
Results 1 to 4 of 4

Help with naming the column when data is impoeted from SQL using VBA

  1. #1
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Help with naming the column when data is impoeted from SQL using VBA

    Hi everyone

    I was wondering whether someone can help me with the following, I am just started to play around with importing data to excel worksheet via SQL connection but am stuck on getting the column headers for my imported data. I can successfully connect to the database and import the data however I am not sure about the code to give the columns the name from the database.

    My code is below
    Please Login or Register  to view this content.
    As I mentioned the data is imported successfully but I need to name each Column. One of the columns in the SQl is called UID_Site and I need this to be called Site when is imported. This is my first column.

    I hope this makes sense and any help is appreciate it

    Thanks in advance

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Help with naming the column when data is impoeted from SQL using VBA

    Try this:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Help with naming the column when data is impoeted from SQL using VBA

    You could also just use the Import from SQL wizard, seems much more simple and it's more flexible

  4. #4
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with naming the column when data is impoeted from SQL using VBA

    This worked great. Thank you so much for your help

+ 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. [SOLVED] Naming a new column in a table
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2014, 01:36 PM
  2. Replies: 0
    Last Post: 01-14-2014, 06:35 PM
  3. Adding ROW using 1 column as reference and another column for naming - BAD title
    By dbondmelo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-21-2013, 12:05 PM
  4. Naming A Column
    By scottintexas in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-28-2008, 01:10 PM
  5. Naming a Column
    By ExcelQuestion in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2008, 11:40 PM
  6. naming a column & naming a cell with a number
    By evanzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2008, 10:49 PM
  7. [SOLVED] naming the column
    By Hemant_india in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2006, 06:24 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