Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Using the values in range of cells in an SQL query

I would like to use the values of a range of cells in an SQL query, but
I'm not sure the best way to do it. Basically, the value of each cell
would be part of a string, each separated by a comma. I could build an
array to loop through each value in the range and append a comma, but is
there a simpler way?

Thank you for your time.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Using the values in range of cells in an SQL query

Demo'd from the immediate window:

v = Application.Transpose( _
Application.Transpose(range("A1").Resize(1,5)))
s = Join(v,",")
? s
AA,BB,CC,DD,EE


if the cells are in a column, you only need one Application.Transpose

--
Regards,
Tom Ogilvy


"steveh" wrote:

I would like to use the values of a range of cells in an SQL query, but
I'm not sure the best way to do it. Basically, the value of each cell
would be part of a string, each separated by a comma. I could build an
array to loop through each value in the range and append a comma, but is
there a simpler way?

Thank you for your time.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Using the values in range of cells in an SQL query

Thanks, Tom. That worked great. I just had to use WorksheetFunction
instead of Application.


Tom Ogilvy wrote:
Demo'd from the immediate window:

v = Application.Transpose( _
Application.Transpose(range("A1").Resize(1,5)))
s = Join(v,",")
? s
AA,BB,CC,DD,EE


if the cells are in a column, you only need one Application.Transpose

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using the values in range of cells in an SQL query

You shouldn't have to - afterall, "demo'd from the immediate window" means
the code was successfully executed. But if it works, I don't see a problem
with that.

--
Regards,
Tom Ogilvy


"steveh" wrote in message
...
Thanks, Tom. That worked great. I just had to use WorksheetFunction
instead of Application.


Tom Ogilvy wrote:
Demo'd from the immediate window:

v = Application.Transpose( _
Application.Transpose(range("A1").Resize(1,5)))
s = Join(v,",")
? s
AA,BB,CC,DD,EE


if the cells are in a column, you only need one Application.Transpose



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
calculate values in an unlimited range of cells in a column WITHOUTalso calculating values that had previously been filtered AGAINST? yadang Excel Discussion (Misc queries) 2 October 1st 09 06:18 PM
Query to take values from Cells Keith Excel Discussion (Misc queries) 1 July 11th 08 11:14 AM
Database query with a range of cells as paramters? heprox Excel Discussion (Misc queries) 0 January 18th 07 11:15 PM
There must be a way!!!--set cells' values equal to calculated values in another range Arnold[_3_] Excel Programming 8 January 1st 07 10:32 PM
loop through cells in a range and pick up corresponding cell values in another range [email protected] Excel Programming 9 October 19th 06 05:11 AM


All times are GMT +1. The time now is 11:37 AM.

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"