Need VBA to join cells into one single cell in other column

skyport

Active Member
Joined
Aug 3, 2014
Messages
374
Need VBA to join cells in column A and put into one single cell in column B. However, the result in column B needs to retain bold and underlining aspects that exist in some of the data in part of each cell in column A

I am currently using the following code which joins the cells ok, however does not retain the parts in bold or underlined that are in column A. Hoping someone can help.

Sub JoinThem2()
Dim i As Long
Dim s As String

For i = 1 To Range("E" & Rows.Count).End(xlUp).Row
s = s & Cells(i, "E").Value
Next i
Range("K1").Value = s
End Sub
 
Roughly how many cells are you joining and what is the total number of characters in K1 when you are finished?
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
the amount of cells could be as many as a few dozen although I only tested your code with 10. Characters landing in cell K1 in unknown until the the program shows a result although is would certainly be under the max cell limit
 
Upvote 0
What version of excel are you running?

And can you post some sample data that has failed? (I can't replicate the failure)
 
Upvote 0
a cell would contain data such as: primary reason for joining would be health and happiness.Step 1: sign up. Step 2: would be to actively participate

there could be a lot more data in cell however, the above is a sample

both 2000 and 2007 Excel
 
Last edited:
Upvote 0
I tried your example data using my code in excel 2010 and it worked for me.

I would expect it the code to work on excel 2007, but I don't think the characters property existed in excel 2000.
 
Upvote 0
Unfortunately I only have excel 2010 and 2013 to test with.
What happens when you step through the macro using a small data set (it can take a while)? Execute it by using the F8 key from the VBE window and F8 to advance line by line and watch the results.
 
Upvote 0
I have tested Teeroy's code in Excel 2007 with about 20 cells, half of which had text as shown in post #14 and about half with shorter text but with some underlined/bold. The total number of characters was >1,000.

It took a little while to run (not surprisingly) but produced the required results as far as I can see.
 
Upvote 0

Forum statistics

Threads
1,216,115
Messages
6,128,923
Members
449,479
Latest member
nana abanyin

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