weird character in cell using vbCrLf

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
In the following code snippet;

strFill = "Query for" & strCommName
strFill = strFill & vbCrLf & strPitHrs
strFill = strFill & vbCrLf & "This query has a rating of"

The cell output is formatted this way;
"Query for SP500
9:30-4:15 EST
This query has a rating of"


And thats how the text shows if you copy and paste it BUT in the cell there is a square box at the end of each of the first two lines. Is the vbCrLf causing that? If so what should I be using instead so the text in the cell shows exactly like the bolded text above
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Thomas

If you select the cell and goto Format>Cells and check Word Wrap on the Alignment tab the square will go away.

The text should also look like you want it, but the vbCrLf will still be there.:)
 
Upvote 0
Yep, well that's what I got when I turned on the macro recorder and did it manually.:)
 
Upvote 0
Setting the wrap text to checked does not remove the square, which by the way is a square with a little ? in it
 
Upvote 0
That square is coming from the text grabbed by the vlookups, as that is the text it is after each time. I just added 3 other vlookup grabs and each has the square after it. Why is the text returned from the vlookup function adding the square?
 
Upvote 0
Thomas

Probably because the cell/range the vlookups are returning the values to aren't formatted to wrap text.

VLOOKUP returns only the value, not the formatting.:)
 
Upvote 0
Nope, that didnt work either. I reset the formatting in the table to wrap text checked and running my sub still put the cell text with the little square
 
Upvote 0
Try formatting after you put the value in.

I've no idea how you are putting the values in but you might be wiping out any existing formatting if you are just doing some straightforward copying.
 
Upvote 0
The correct answer is the vbCrLf needed to be changed to vbLf. The vbCrLf is what was adding the little square character
 
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,222
Members
448,877
Latest member
gb24

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