#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default String of Numbers

I have a list of numbers;
For example
23489
52356
23563

I want to change into this precise format = '23489','52356','23563'

However CONCATENATE function will not help because list of number can very
in length from one week to another.

Does anybody have an idea of how to create a tool in either excel or access
to give me that precise format no matter how long my list of numbers is?

Thanks for any help,
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default String of Numbers

On Mon, 29 Dec 2008 14:08:02 -0800, KLock
wrote:

I have a list of numbers;
For example
23489
52356
23563

I want to change into this precise format = '23489','52356','23563'

However CONCATENATE function will not help because list of number can very
in length from one week to another.

Does anybody have an idea of how to create a tool in either excel or access
to give me that precise format no matter how long my list of numbers is?

Thanks for any help,



Here is a UDF (user defined function) that should do that:

========================
Option Explicit
Function ConcatRange(rg As Range)
Dim d() As String
Dim i As Long
ReDim d(rg.Count - 1)

For i = 0 To UBound(d)
d(i) = "'" & rg(i + 1).Text & "'"
Next i

ConcatRange = Join(d, ",")

End Function
=============================

The formula would be =ConcatRange(range_reference)

Range_reference might be A1:A10

To enter this, alt-F11 opens the VBEditor. Ensure your project is highlighted
in the project explorer window, then Insert/Module and paste the code above
into the window that opens.

The UDF does not take into account blank entries, but could be modified to
handle that, if you wish.
--ron
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default String of Numbers

Suppose your numbers are in Col A starting at A1
enter this in B1
="'" & A1& "'"

enter this in B2
=IF(A2="",B1, B1 & ",'" & A2 & "'")

Copy this down beyond the maximum numbers you expect... and last cell in Col
B will give you the string

"KLock" wrote:

I have a list of numbers;
For example
23489
52356
23563

I want to change into this precise format = '23489','52356','23563'

However CONCATENATE function will not help because list of number can very
in length from one week to another.

Does anybody have an idea of how to create a tool in either excel or access
to give me that precise format no matter how long my list of numbers is?

Thanks for any help,

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default String of Numbers

Hi,

One thing to keep in mind in 2003 - the maximumn number of characters in a
formula is 1024 so if your string of numbers is long you may bump up against
this limit.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"KLock" wrote:

I have a list of numbers;
For example
23489
52356
23563

I want to change into this precise format = '23489','52356','23563'

However CONCATENATE function will not help because list of number can very
in length from one week to another.

Does anybody have an idea of how to create a tool in either excel or access
to give me that precise format no matter how long my list of numbers is?

Thanks for any help,

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default String of Numbers

The best way is with a UDF function

Call function with following from worksheet
= JoinF(A1:A10) or any number of cells.

I didn't include the equal sign because I wasn't sure if that was part of
the format. It is easy to add the equal sign if necessary.


Function JoinF(target As Range) As String

JoinF = ""
For Each cell In target
If JoinF = "" Then
JoinF = "'" & cell & "'"
Else
JoinF = JoinF & ",'" & cell & "'"
End If

Next cell

End Function

"KLock" wrote:

I have a list of numbers;
For example
23489
52356
23563

I want to change into this precise format = '23489','52356','23563'

However CONCATENATE function will not help because list of number can very
in length from one week to another.

Does anybody have an idea of how to create a tool in either excel or access
to give me that precise format no matter how long my list of numbers is?

Thanks for any help,

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
formatting of numbers within a string Edward Excel Worksheet Functions 8 November 1st 07 08:13 PM
Concatinating a string of numbers - how? drod Excel Discussion (Misc queries) 5 August 2nd 06 10:02 PM
Column of Numbers in xls to String of Numbers in txt Spyder Excel Discussion (Misc queries) 1 March 15th 06 07:39 PM
string of numbers David Excel Worksheet Functions 1 May 20th 05 08:19 PM
string of numbers BorisS Excel Worksheet Functions 0 May 20th 05 07:16 PM


All times are GMT +1. The time now is 05: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"