Excel 2010 - Adding Punctuation Around Values in Rows

Posted on 2014-01-23
Medium Priority
Last Modified: 2014-01-23
Good Day Experts!

I am a novice  at Excel 2010 and am not sure if what I wish to do is possible.

I have 6541 rows with values only in column A.  The values are 4 long and have up to 3 preceeding 0's.  I would like to put ' in front and in back of the value('0002').  Then I would like to put all the values together in a string seperated by a comma('0002','0003','0004' etc).

Bascially I am going to use these values in a SQL query.

Question by:Jimbo99999
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 43

Accepted Solution

Saqib Husain, Syed earned 1000 total points
ID: 39803391
If your data starts in A2 then enter these formulas

B2:      =TEXT(A2,"'0000',")

C2:      =B2&C1

and copy them both all the way down.
LVL 23

Assisted Solution

NBVC earned 1000 total points
ID: 39803392
Perhaps with a UDF....

press ALT+F11 to go to VB editor, then Insert|Module.

Paste this in the Editor:

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant

If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
aconcat = aconcat & a & sep
End If

aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function

Open in new window

Then in the sheet, use formula in an empty cell:


adjust range to suit.
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39803401
That was close!!!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 23

Expert Comment

ID: 39803488
Yes, only 1 second :)
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39803569
Did you scratch you eyebrow before posting?
LVL 23

Expert Comment

ID: 39803685
I sneezed ;)

Expert Comment

by:Naresh Patel
ID: 39804520
this is ony suggestion i guess he needs this way assuming data start in column A from Cell A1 then formual in Cell B1

Open in new window

                                Cell B2

Open in new window

and just formula dropdown.

See Attached file.


Author Closing Comment

ID: 39804573
Thanks everyone.  The nedd/requirement was retracted from my assignment.  However, I have wondered how to do this type of "stuff" in the past.  So I will definitely put it in my knowledge base.


Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question