Excel guru question..

B

Bryan S. Slick

I have a table, 4w x 10h.

I input data into A1-A10 and B1-B10. The data is converted into values
in C1-C10 and D1-10.

I need the data in the following format:

C1,D1 C2,D2 C3,D3 C4,D4 C5,D5 C6,D6 C7,D7 C8,D8 C9,D9 C10,D10

....all in one cell and with the commas included.


I know there's a way to do this, but damn if I can remember it.

Anyone?


--
Bryan S. Slick, onyx_hokie at yahoo dot com

"Violence is the last refuge of the incompetent."

(Salvor Hardin in 'Foundation', Isaac Asimov)
 
G

Gord Dibben

You could do it manually, but a macro is much quicker.

Sub ConCat_Cells()
Dim x As Range
Dim y As Range
Dim z As Range
Dim w As String
Dim sbuf As String
On Error GoTo endit
w = InputBox("Enter the Type of De-limiter Desired") 'comma or whatever
Set z = Application.InputBox("Select Destination Cell", _
"Destination Cell", , , , , , 8)
Application.SendKeys "+{F8}"
Set x = Application.InputBox("Select Cells...Contiguous or Non-Contiguous", _
"Cells Selection", , , , , , 8)
For Each y In x
If Len(y.text) > 0 Then sbuf = sbuf & y.text & w
Next
z = Left(sbuf, Len(sbuf) - 1)
Exit Sub
endit:
MsgBox "Nothing Selected. Please try again."
End Sub

At the point where you are asked to Select Cells, select the range C1:D10


Gord Dibben MS Excel MVP
 
B

Bryan S. Slick

[ Sat, 01 Jul 2006 11:11:46 -0700 ]
[ | Gord Dibben <gorddibbATshawDOTca> ]
[ <[email protected]> ]

:You could do it manually, but a macro is much quicker.
:
:Sub ConCat_Cells()
:Dim x As Range
:Dim y As Range
:Dim z As Range
:Dim w As String
:Dim sbuf As String
: On Error GoTo endit
: w = InputBox("Enter the Type of De-limiter Desired") 'comma or whatever
: Set z = Application.InputBox("Select Destination Cell", _
: "Destination Cell", , , , , , 8)
: Application.SendKeys "+{F8}"
: Set x = Application.InputBox("Select Cells...Contiguous or Non-Contiguous", _
: "Cells Selection", , , , , , 8)
: For Each y In x
: If Len(y.text) > 0 Then sbuf = sbuf & y.text & w
: Next
: z = Left(sbuf, Len(sbuf) - 1)
: Exit Sub
:endit:
: MsgBox "Nothing Selected. Please try again."
:End Sub
:
:At the point where you are asked to Select Cells, select the range C1:D10

Thanks!

--
Bryan S. Slick, onyx_hokie at yahoo dot com

"Violence is the last refuge of the incompetent."

(Salvor Hardin in 'Foundation', Isaac Asimov)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top