+ Reply to Thread
Results 1 to 3 of 3

SQL Pivot function with a text file database within Excel

  1. #1
    Registered User
    Join Date
    04-22-2014
    Location
    nyc
    MS-Off Ver
    Excel 2007
    Posts
    1

    SQL Pivot function with a text file database within Excel

    I'm more or less a beginner and we do not have access to SQL server/access at work so I have to design an app within Excel VBA and using a text file (CSV) to store the data.

    I have no problem querying data, joining the CSV's, but I would like to use the SQL Pivot/Unpivot statement to transpose one of the columns into rows. I'm not sure if that functionality exists as I keep getting the error that there's a syntax error in my FROM clause.

    Please Login or Register  to view this content.
    My data currently looks like the top of the picture and I want it to look like the bottom.

    ex.png

    This is simple enough to do with a pivot table but I wanted the user to be able to type over the data.

    Additionally, is there anyway to make it dynamic because there will be an unknown number of possible clients so the number of rows would need to expand.

    thanks in advance

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

    Re: SQL Pivot function with a text file database within Excel

    I'm not sure why you need to allow your users to type over the data, but an alternative means would be to import the data and use a pivot table to group and format the data. Then "overlay" the pivot table with a named dynamic range and then copy the named range into an excel table or just a plain range. I recommend a table if there are formulas, data validations, etc. involved.

    The user should be able to type in this table.
    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
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: SQL Pivot function with a text file database within Excel

    Hi,

    That is not the correct syntax for a crosstab query with the Jet provider. Your code needs to be thus:
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

+ 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. Excel Database with non pivot table format
    By marcomojarro in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-22-2015, 09:21 PM
  2. [SOLVED] text based file import, database populate and then export.
    By R2dical in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-27-2013, 06:12 PM
  3. copy data from text file or from SQL database into cells in excel
    By veD_DeXTer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-30-2012, 03:02 AM
  4. Importing text file to excel database
    By tek in forum Excel General
    Replies: 3
    Last Post: 05-29-2007, 07:41 AM
  5. How to use Database file in Excel
    By tqm1 in forum Excel General
    Replies: 3
    Last Post: 04-30-2007, 04:34 AM
  6. [SOLVED] VBA Code to create PIVOT in Excel from access database
    By ST in forum Excel General
    Replies: 1
    Last Post: 07-26-2006, 01:45 PM
  7. Excel as Database - Pivot Question
    By DCSwearingen in forum Excel General
    Replies: 2
    Last Post: 06-21-2006, 06:05 PM

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