Concatenating a "=" to a text string.

___AW

New Member
Joined
Dec 11, 2014
Messages
5
I am running a program to reformat some text from one character per line to a string of text. It works fine until it hits some text that has the value of "=". Then I get a "Run-time error '1004': Application-defined or object-defined error". Is there a workaround for this? The code that does the concatenate is as follows:

Cells(RowRefDest, 1).Value = Cells(RowRefDest, 1).Value & Cells(RowRefSrc, 1).Value

Thanks.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
That's because it will try and interpret that as a formula, try this:

Code:
Cells(RowRefDest, 1).Value = "'=" & Cells(RowRefDest, 1).Value & Cells(RowRefSrc, 1).Value
 
Upvote 0
I am running a program to reformat some text from one character per line to a string of text. It works fine until it hits some text that has the value of "=". Then I get a "Run-time error '1004': Application-defined or object-defined error". Is there a workaround for this? The code that does the concatenate is as follows:

Cells(RowRefDest, 1).Value = Cells(RowRefDest, 1).Value & Cells(RowRefSrc, 1).Value
Do I understand you correctly that you have data that looks something like this...

Excel 2010
A
1M
2y
3
4D
5a
6t
7a

<colgroup><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

and you want it to look like this...


Excel 2010
AB
1MMy Data
2y
3
4D
5a
6t
7a
Sheet2


If so, you can do it with a single line of code (albeit a rather long one)...
Code:
Range("[B][COLOR="#0000FF"]B[/COLOR][/B]1").Value = Replace(Replace(Join(Application.Transpose(Range("[B][COLOR="#FF0000"]A[/COLOR][/B]1", Cells( _
                    Rows.Count, "[B][COLOR="#FF0000"]A[/COLOR][/B]").End(xlUp)).Value), ","), ",,", " "), ",", "")

The two red A's are the source column's letter designation and the blue B is the destination column's letter designation.
 
Upvote 0
Try
Code:
Cells(RowRefDest, 1).Value = "'" & Cells(RowRefDest, 1).Value & Cells(RowRefSrc, 1).Value
 
Upvote 0
Thanks to all of you. Sorry for the slow feed back, but I just finally got back on this. Actually none of those worked. What did end up working was setting the entire column to Text format before processing it. The source cell value that I was trying to concatenate was a "=", so I just had to format it as a text field before concatenating it.

Rick, thanks for your transpose formula. That is what I was doing, I only had to adjust the formula ranges to match exactly what I was trying to do. That made the macro run much quicker!
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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