Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sure, you could do that. Assuming that the data is pasted in Sheet1,
starting in A2 and below: Sub MakeSQL() Dim i As Long Dim Sql As String With Sheets("Sheet1") For i = 2 To .Cells(.Rows.Count, 1).End(xlUp).Row Sql = Sql & ",'" & .Cells(i, 1).Value & "'" Next i Sql = Mid$(Sql, 2) End With Sql = "select month, sum(sales_amount) from CompanySales where Company_Name in (" Sql & ") group by month;" End Sub I assumed that you have to enclose the texts within single quotes, as usual... -- Regards Juan Pablo González "Rob" wrote in message ... I have a need for our business customers to be able to insert a list of customers then chart their performance. The data is stored in SQL Server. I would like for them to be able to paste a list of customers into the spreadsheet and then use that list in my database query. There are about 8000 customers and most of the lists would have about 100 of the customers. An example would be them pasting a list like this into Sheet 1: company ABC company 123 Company XYZ I would want my query to look like this: select month, sum(sales_amount) from CompanySales where Company_Name in (company ABC, company 123, Company XYZ) group by month; Then I could create an Excel chart on the returned data. Is there any way to do this or would this have to be done with some kind of filter? Thanks, Rob |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 / MS Query - editing existing query to another sheet | Excel Discussion (Misc queries) | |||
Can I use MS Query in Excel like an Append Query in Access | Excel Discussion (Misc queries) | |||
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? | Excel Discussion (Misc queries) | |||
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? | Excel Discussion (Misc queries) | |||
How to use a Access Query that as a parameter into Excel database query | Excel Discussion (Misc queries) |