ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find function using chr (https://www.excelbanter.com/excel-programming/397387-find-function-using-chr.html)

gazza67[_2_]

Find function using chr
 
Hi,

I have a single cell with text that contains multiple lines (ie text
separated by a chr(10) I think).

I want to get the text from the cell starting with the first character
up untill but not including the first chr(10).

I presume you use a combination of LEFT , FIND and CHR(10) - but I
just cant seem to get the syntax right.

Could anyone out there help me with this simple problem?

Gary


OssieMac

Find function using chr
 
Hi Gary,

Not sure if you want a worksheet formula or a VBA formula because the post
is in a programming forum and examples are worksheet so here is both:-

Worksheet formula assuming cell A1 has the value:-
=LEFT(A1,FIND(CHAR(10),A1)-1)

VBA formula assuming cell A1 has the value:-
Dim strTest as String
strTest = Left(Range("A1"), InStr(1, Range("A1"), Chr(10)) - 1)

Regards,

OssieMac




All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com