Creating a text string from multiple cells of data

kc_native

Board Regular
Joined
Jan 20, 2009
Messages
176
I have been tasked with doing a database search of a list of part numbers some 3,300 items long. In order to search the database, I have to enter the part numbers in SQL code in the following format: ('number','number','number',......). I am hoping that there is some code that someone can suggest that will take the contents of each cell in a column, and put them together in that format in a single cell. It is my understanding that there is a capacity of 32,767 characters per cell in Excel 2010, so there should be enough room for my 3,300 cells of part numbers, which average 8 characters each.

Any help would be greatly appreciated.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
If you can give more information, we may be able to figure out an efficient way to do what you need.
• What kind of database are you querying? (MS Access, SQL Server, Oracle, other?)
• What tool are you using to perform the query?
 
Upvote 0
If you can give more information, we may be able to figure out an efficient way to do what you need.
• What kind of database are you querying? (MS Access, SQL Server, Oracle, other?)
• What tool are you using to perform the query?
It is an Oracle database, and I am using a query that was written in SQL Developer to query the database. The relevant line in the query is as follows:
Code:
and ob.tool_no like '%number%'  ("number" is the variable part I am searching for)
 
Upvote 0
Do you really need the wildcards in the LIKE clause? Or would the ob.tool_no actually match an item in your list?
 
Upvote 0
Do you really need the wildcards in the LIKE clause? Or would the ob.tool_no actually match an item in your list?
The wildcards are there because we have parts with the same base number, but a different prefix or suffix, and we might want to search for all possible combinations.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top