+ Reply to Thread
Results 1 to 3 of 3

How to apply credentials in VBA to refresh extracted data from SQL Server on Excel?

  1. #1
    Registered User
    Join Date
    03-11-2021
    Location
    dubai
    MS-Off Ver
    2016
    Posts
    2

    Question How to apply credentials in VBA to refresh extracted data from SQL Server on Excel?

    I have an Excel file where it is connected to multiple tables from an SQL Server. This is how I connected it.

    Data Connection.png

    All the tables are loaded fine on the sheet, however these tables are a reference to specific actions on Excel so they need to be up to date on Excel itself. The sheet is going to be used by multiple users, so I have set a macro that when they press a button all tables gets refreshed in their Excel files so the data is always up to date.

    It works perfectly for me as I have a username and password for the database, however these users don't have a username and password. Once they click the button to refresh the data, they get a pop up to enter the database credentials.

    PN8QD.png

    What I am trying to do is apply my own credentials in the VBA code of that button, so once they click the refresh button, all tables in excel gets refreshed and excel doesn't ask the user for credentials.

    If anyone has a way of doing it, please let me know.

    Thanks.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to apply credentials in VBA to refresh extracted data from SQL Server on Excel?

    I had to do something similar to this using an oracle database. We made an ODBC data connection to the database. With this option, there was an option to save the credentials.

    There is a way to manipulate the credentials by updating the connection string on the connection. It uses a short piece of VB code. with split and join.

    Try making an ODBC connection using the SQL Server driver and see if you have the option to remember the credentials.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    03-11-2021
    Location
    dubai
    MS-Off Ver
    2016
    Posts
    2

    Re: How to apply credentials in VBA to refresh extracted data from SQL Server on Excel?

    Thanks for your reply, but I am still new to this stuff, can you help me with the coding of the VBA for such a thing? I tried multiple examples that I saw online but nothing seemed to work for me.

+ 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. Replies: 1
    Last Post: 09-01-2020, 03:26 AM
  2. Replies: 0
    Last Post: 08-31-2020, 08:15 PM
  3. Email Link in Extracted data from Outlook to Excel
    By Crazylanz05 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2020, 10:20 AM
  4. macro to automatically refresh a data set from a SQL server
    By septim in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2013, 12:32 AM
  5. Replies: 0
    Last Post: 02-21-2013, 09:07 AM
  6. Excel 2007 : excel : refresh once and apply filters
    By muralivelaga in forum Excel General
    Replies: 0
    Last Post: 05-12-2009, 05:45 AM
  7. Excel Add-in for SQL Server Analysis Services - refresh problem
    By Inge M. Bruvik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2005, 04:07 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