LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Source Data Code Cleanup Help

I'm writing some code to create pivot tables from an SQL database that was
created several years ago. Unfortunately, the person that created the
database used table names and field names with lots of spaces in them. For
starters, I have no opportunity to change the names. I've recorded the
macro below to create the pivot and select the source data. However, I'd
like to clean it up a bit for two reasons:
1) Make it easier to read so that field names are split on multiply lines
and
2) Add variables for the server and database names so I can use an input box
to change these at the start. (The server in the example is
"JMICHL_03\SQL2000" and the database is "POSData".

My problem is that when I try to edit the code below I can't seem to get the
the quotes in proper places so as to not generate errors. In addition, I
can't seem to figure out how to put a variable into this string that would
substitute a new server or database name. Could someone edit the code below
enough to give me an idea of where the quotes should be?

If it isn't obvious 'Customer Period / Type' is a table within the
database.

Thanks! - John

ActiveSheet.PivotTableWizard SourceType:=xlExternal,
SourceData:=Array( _
"SELECT ""Customer Period / Type"".""Sales Organization ID"",
""Customer Period / Type"".""Period ID"", ""Customer Period /
Type"".""Customer Type"", ""Customer Period / Type"".""Current Sales Org
Decile"", ""Customer Period / Type"".""Prior " _
, _
"Revenue Centile""" & Chr(13) & "" & Chr(10) & "FROM
""POSData"".dbo.""Customer Period / Type"" ""Customer Period / Type"",
""POSData"".dbo.""Sales Organizations"" ""Sales Organizations""" & Chr(13) &
"" & Chr(10) & "WHERE ""Sales Organizations"".ID = ""C" _
, "ustomer Period / Type"".""Sales Organization ID"""),
Connection:=Array( _
Array( _
"ODBC;DRIVER=SQL
Server;SERVER=JMICHL_03\SQL2000;UID=JMichl;APP=Mic rosoft Office
XP;WSID=JMICHL_03;DATABASE=POSData;Trusted_" _
), Array("Connection=Yes"))


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data cleanup sjs Excel Worksheet Functions 1 September 16th 09 03:37 PM
Updating Source Code in Charts University Charts and Charting in Excel 0 September 19th 06 08:12 PM
Hard-code source data Melanie Martin Charts and Charting in Excel 5 December 29th 05 02:07 PM
Pivot Table data source "data source contains no visible tables" Jane Excel Worksheet Functions 0 September 29th 05 08:28 PM
source code for copyright Steve[_31_] Excel Programming 1 August 9th 03 11:10 PM


All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"