ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count number of characters until encounter "&" (https://www.excelbanter.com/excel-programming/371796-count-number-characters-until-encounter.html)

belkingold

Count number of characters until encounter "&"
 
I have a cell with the value "577256&S_MSGNUM=4777037808398&". I want
to count the number of characters that appear before the first & symbol
so I can do a left() on them. They are always integers, never letters.


Bernie Deitrick

Count number of characters until encounter "&"
 
=LEFT(A1,FIND("&",A1)-1)

or

=VALUE(LEFT(A1,FIND("&",A1)-1))

HTH,
Bernie
MS Excel MVP


"belkingold" wrote in message
oups.com...
I have a cell with the value "577256&S_MSGNUM=4777037808398&". I want
to count the number of characters that appear before the first & symbol
so I can do a left() on them. They are always integers, never letters.




Die_Another_Day

Count number of characters until encounter "&"
 
CharactersBefore& = Instr(1,"577256&S_MSGNUM=4777037808398&", "&") - 1

Charles

belkingold wrote:
I have a cell with the value "577256&S_MSGNUM=4777037808398&". I want
to count the number of characters that appear before the first & symbol
so I can do a left() on them. They are always integers, never letters.



titus

Count number of characters until encounter "&"
 

belkingold wrote:
I have a cell with the value "577256&S_MSGNUM=4777037808398&". I want
to count the number of characters that appear before the first & symbol
so I can do a left() on them. They are always integers, never letters.


Put your value in A1
Put & in A2
Put this code in A3 =LEFT(A1,FIND(A2,A1)-1)

Titus


Bernie Deitrick

Count number of characters until encounter "&"
 
Yikes! VBA:

Sub TryNow()
Dim myStr As String
Dim myVal As Double

myStr = Left(Range("A1").Value, InStr(1, Range("A1").Value, "&") - 1)
MsgBox myStr
myVal = CDbl(myStr)
MsgBox Format(myVal, "0.00")
End Sub

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
=LEFT(A1,FIND("&",A1)-1)

or

=VALUE(LEFT(A1,FIND("&",A1)-1))

HTH,
Bernie
MS Excel MVP


"belkingold" wrote in message
oups.com...
I have a cell with the value "577256&S_MSGNUM=4777037808398&". I want
to count the number of characters that appear before the first & symbol
so I can do a left() on them. They are always integers, never letters.







All times are GMT +1. The time now is 04:24 PM.

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