ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   split 1.5/2.1 into 1.5 and 2.1 (https://www.excelbanter.com/excel-programming/434635-split-1-5-2-1-into-1-5-2-1-a.html)

OkieViking

split 1.5/2.1 into 1.5 and 2.1
 
I have a cell with numbers in the following format 1.5/2.1. Is there a way
of picking the numbers out of that so I can populate two cells with 1.5 and
2.1?

Jacob Skaria

split 1.5/2.1 into 1.5 and 2.1
 
'VBA
strData = "1.5/2.1"
Range("B1") = Split(strData,"/")(0)
Range("C1") = Split(strData,"/")(1)

'Worksheetfunction
=LEFT(A1,Find("/",A1)-1)
=MID(A1,Find("/",A1)+1,len(A1))


If this post helps click Yes
---------------
Jacob Skaria


"Okieviking" wrote:

I have a cell with numbers in the following format 1.5/2.1. Is there a way
of picking the numbers out of that so I can populate two cells with 1.5 and
2.1?


Rick Rothstein

split 1.5/2.1 into 1.5 and 2.1
 
'VBA
strData = "1.5/2.1"
Range("B1") = Split(strData,"/")(0)
Range("C1") = Split(strData,"/")(1)


Or, since we are going across columns, more simply...

strData = "1.5/2.1"
Range("B1:C1") = Split(strData, "/")

Note to the OP... Jacob (and I) used a String variable (strData) to hold
your values, but this value can come directly from a cell as well... just
replace strData with Range("A1") assuming your cell is A1, of course.

--
Rick (MVP - Excel)



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

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