vbLf & text wrapping - inconsistent behaviour

mzza

Board Regular
Joined
Nov 8, 2006
Messages
55
Hi there,

my current project includes code to pass selected Terms and Conditions on one tab onto a Quotation tab for printout.

Code:
Sheets("Ts & Cs").Select

Last_Row_TsCs = Sheets("Ts & Cs").Range("B" & Rows.Count).End(xlUp).Row

    Range("A1").Select
    Selection.AutoFilter Field:=1, Criteria1:="x"

    For i = 2 To Last_Row_TsCs
        If Sheets("Ts & Cs").Cells(i, 1) = "x" Then TsCs_String = TsCs_String & Sheets("Ts & Cs").Cells(i, 2).Text & vbLf
    Next i

    Range("A1").Select
    Selection.AutoFilter Field:=1

Sheets("Quote").Select
Range("C67:BA95").Value = TsCs_String

Range C67:BA95 is a single merged cell, with the "wrap text" option selected under the cell's formatting options. I know, not ideal, but I'm walking before I can run.

I've tested this by selecting a few of the Ts&Cs. Strangely, the first two selected Ts&Cs appear as I would expect - paragraphs with line breaks and proper text wrapping - but, for any subsequent Ts&Cs, the text doesn't wrap (instead, it disappears off the right-hand edge of the cell)

Any clue as to why this might be happening? Or better yet, how to fix it?

TIA

mzza
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
In an effort to circumvent the problem, I have created a new one...

instead of using a merged cell, I created a textbox (direct from the spreadsheet under the 'Draw' menu) which I am now trying to populate with text based on my coded string, viz:

Code:
ActiveSheet.Shapes("Text Box 26").Select
    Selection.Characters.Text = TsCs_String

There are no errors when the code is run, and the 'TsCs_String' retains its expected value - it just isn't being passed to the textbox correctly.

Any advice...?

TIA

mzza
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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