separate something in a cell.

8700Rakf

New Member
Joined
May 15, 2019
Messages
32
So i have a cell with which as the following in it - 100 > m > 10000 - In my case its in cell A21

Is it possible to write a code that seperates the 100 and 1000 to another variable?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Or use a helper column

in B21
=SUBSTITUTE(A21," > ","")
then use Text To Columns with a separater of m
This assumes that m will always be in the cell between the > signs

One piece of data does not test data make.
 
Upvote 0
Then you would have to handle it like an array?
If you use the VBA Split functionality, yes.
The last example in the link I provided shows an example of that.

It would look something like this:
Code:
Sub Test()

Dim LString As String
Dim LArray() As String
Dim ub As Long
Dim firstValue, lastValue

LString = Range("A21")
LArray = Split(LString, ">")

'Find number of values in array
ub = UBound(LArray)

'Get first and last values in the array
firstValue = Trim(LArray(0))
lastValue = Trim(LArray(ub))

MsgBox firstValue
MsgBox lastValue

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,545
Messages
6,120,132
Members
448,947
Latest member
test111

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