Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ForestFeeder
 
Posts: n/a
Default Anyone actually get Case statement to work ... ?

Has anyone successfully used the Case statement in a select query using MS
SQL within Excel , looking at an excel file as a datasource?

I'd love for you to post a sample query that you got to work. I've followed
the syntax every which way and it doesnt seem to work on this configuration.
Much appreciated !
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
William Horton
 
Posts: n/a
Default Anyone actually get Case statement to work ... ?

Not sure if this is what you want/need but it works for me in a macro.

Sub test()
Dim MWS As Worksheet, X As String
Set MWS = ThisWorkbook.Worksheets(1)
Select Case MWS.Range("A1")
Case 1
MsgBox "case was 1"
Case 2
MsgBox "case was 2"
Case 3
MsgBox "case was 3"
Case Else
MsgBox "case was not 1 or 2 or 3"
End Select
End Sub

Hope that is a start.

"ForestFeeder" wrote:

Has anyone successfully used the Case statement in a select query using MS
SQL within Excel , looking at an excel file as a datasource?

I'd love for you to post a sample query that you got to work. I've followed
the syntax every which way and it doesnt seem to work on this configuration.
Much appreciated !

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ForestFeeder
 
Posts: n/a
Default Anyone actually get Case statement to work ... ?

Thanks Bill,
Unfortunately I need to use SQL in Microsoft Query within Excel.

I have an excel file ( A ) which acts as a database. Another excel file ( B
) is a report that queries the database ( A ).

My SQL query requires the use of a case statement.
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Duke Carey
 
Posts: n/a
Default Anyone actually get Case statement to work ... ?

Until you posted this I hadn't tried. However, now that I've tried it isn't
looking so good. A simple case select that runs fine in SQL Server Query
Analyzer returns no records when run against an Excel file containing the
same SQL data.

I can't even get MS Query to accept a rudimentary CASE statement



"ForestFeeder" wrote:

Has anyone successfully used the Case statement in a select query using MS
SQL within Excel , looking at an excel file as a datasource?

I'd love for you to post a sample query that you got to work. I've followed
the syntax every which way and it doesnt seem to work on this configuration.
Much appreciated !

Reply
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
count colored cells? DKY Excel Worksheet Functions 21 January 19th 06 09:47 PM
color coding Ardilla Excel Worksheet Functions 1 January 11th 06 08:49 PM
VBA Code Cell Mate Excel Discussion (Misc queries) 4 January 9th 06 08:52 PM
EXCEL:NUMBER TO GREEK WORDS vag Excel Worksheet Functions 1 June 15th 05 05:57 PM
reminder notifications in a column L Mieth Excel Discussion (Misc queries) 6 June 10th 05 11:00 AM


All times are GMT +1. The time now is 12:35 AM.

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

About Us

"It's about Microsoft Excel"