Help with Strings in Cells that use alt key Returns

davlcam

New Member
Joined
Aug 4, 2009
Messages
45
Im using a simple identification sequence to apply ID numbers to rows.

The code looks like this:
Code:
For each x in Range (B5:B200)

If x ="Text in the Cell" the x Offset(0, -1) Value = "ID #1"
(repeat until all ID's are cylcled)

Next
So my problem is I have a few cells with strings that have alt returns in them.

For example: The string in cell B20 is -

Code:
1. Antibiotics within a hour cut time
     (overall rate)
(There is an alt return after the word 'time')

If my x line is:

Code:
If x ="1. Antibiotics within an hour cut time      (overall rate)" ...
The code does not recognize the line.

Ive had success with this code in the past, but the alt return in the cell is breaking it. Any help would be appreciated.
 

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.
Still looking for help on this.

I assume I need to use the underscore '_' somewhere in there, but I cant figure out how to do it...
 
Upvote 0
Try use chr(10) or chr(13)

If x="first line text" & chr(10) & "second line text"

Haven't tested it as I am not near a computer
 
Upvote 0
Maybe

Code:
    If WorksheetFunction.Trim(Replace(x.Value, vbLf, "")) = "Text in the Cell" Then
 
Upvote 0
Try use chr(10) or chr(13)

If x="first line text" & chr(10) & "second line text"

Haven't tested it as I am not near a computer


I thought it might be an easy one. Thanks very much. chr(10) did it.

Edit:
Didnt see your post shg, may try that too , thanks.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

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