Solved

Excel 2010 - Adding Punctuation Around Values in Rows

Posted on 2014-01-23
8
258 Views
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.

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
8 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 250 total points
Comment Utility
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.
0
 
LVL 23

Assisted Solution

by:NBVC
NBVC earned 250 total points
Comment Utility
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
Else
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:

="'"&aconcat(A1:A6541,"',")&"'"

adjust range to suit.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
That was close!!!
0
 
LVL 23

Expert Comment

by:NBVC
Comment Utility
Yes, only 1 second :)
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
Did you scratch you eyebrow before posting?
0
 
LVL 23

Expert Comment

by:NBVC
Comment Utility
I sneezed ;)
0
 
LVL 8

Expert Comment

by:itjockey
Comment Utility
this is ony suggestion i guess he needs this way assuming data start in column A from Cell A1 then formual in Cell B1
="'"&A1&"',"

Open in new window


                                Cell B2
=B1&"'"&A2&"',"

Open in new window

and just formula dropdown.


See Attached file.


Thanks
Join.xlsx
0
 

Author Closing Comment

by:Jimbo99999
Comment Utility
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.

jimbo99999
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now