return text after 2nd occurrence of an equal sign (=)

andymalan

Board Regular
Joined
Feb 22, 2017
Messages
65
Hello
i have to extract numbers from a string in Col G (varying rows) the data looks like this

Width = 760, Depth = 350
Width = 1610, Height = 50, Depth = 16
Width = 1610, Depth = 350

my formula in col H

<colgroup><col></colgroup><tbody>
</tbody>

<colgroup><col></colgroup><tbody>
</tbody>

MID(LEFT(G80,FIND(",",G80)-1),FIND("=",G80)+1,LEN(G80)) returns the first part i.e. 760; 1610; 1610

what formula can I use to return (in Col I) the second occurrence i.e. 350; 50; 350

your help will really be appreciated.
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

kweaver

Well-known Member
Joined
May 8, 2018
Messages
1,049
Office Version
365, 2010
I put the various numbers in H through Nth column (n = however many numbers are in the string(s) in G)

Code:
Sub ExtractNums()
Dim strg() As String, i As Integer, j As Integer, w As Long, k As Long, LR As Long
LR = Cells(Rows.Count, "G").End(xlUp).Row
For i = 1 To LR
k = 8
strg = Split(Range("G" & i), ",")
 For j = 0 To UBound(strg)
 w = WorksheetFunction.Find("=", strg(j))
 Cells(i, k) = 1 * Right(strg(j), Len(strg(j)) - w)
 k = k + 1
 Next j
Next i
End Sub
 
Last edited:

AhoyNC

Well-known Member
Joined
Oct 10, 2011
Messages
4,518
Office Version
365
Platform
Windows
With a formula.
Excel Workbook
GHI
1Width = 760, Depth = 350
350
2Width = 1610, Height = 50, Depth = 1650
3Width = 1610, Depth = 350350
Sheet
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
Hi,

If, according to your description, you don't care for the Order of the data (i.e. Width, Depth, Height), you Just want the 1st, 2nd, and 3rd numeric values extracted, use this in Column H, copied down and across to Column J, results are converted to Real numbers:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>G</th><th>H</th><th>I</th><th>J</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">Width = 760, Depth = 350</td><td style="text-align: right;;">760</td><td style="text-align: right;;">350</td><td style=";"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">Width = 1610, Height = 50, Depth = 16</td><td style="text-align: right;;">1610</td><td style="text-align: right;;">50</td><td style="text-align: right;;">16</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">Width = 1610, Depth = 350</td><td style="text-align: right;;">1610</td><td style="text-align: right;;">350</td><td style=";"></td></tr></tbody></table><p style="width:6.4em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet702</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">H1</th><td style="text-align:left">=IFERROR(<font color="Blue">MID(<font color="Red">SUBSTITUTE(<font color="Green">SUBSTITUTE(<font color="Purple">$G1,"=",REPT(<font color="Teal">" ",100</font>)</font>),",",REPT(<font color="Purple">" ",100</font>)</font>),(<font color="Green">COLUMNS(<font color="Purple">$H1:H1</font>)*2-1</font>)*100,100</font>)+0,""</font>)</td></tr></tbody></table></td></tr></table><br />

PS, formula can be copied across to as many Columns as you need if there are more than 3 numbers in the original text string.
 
Last edited:

trunten

Active Member
Joined
Jul 26, 2011
Messages
478
With your example of Cell G80

Column H:
=VALUE(MID(LEFT(G80,FIND(",",G80)-1),FIND("=",G80)+1,LEN(G80)))

Column I:
=VALUE(MID(G80,FIND("=",SUBSTITUTE(G80,"="," ",1))+1,LEN(G80)))
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,950
Office Version
2007
Platform
Windows
Another way

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:225.27px;" /><col style="width:155.88px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >G</td><td >H</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td >Width = 760, Depth = 350</td><td style="text-align:right; ">350</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td >Width = 1610, Height = 50, Depth = 16</td><td style="text-align:right; ">50</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td >Width = 1610, Depth = 350</td><td style="text-align:right; ">350</td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td ></td><td ></td></tr><tr><td >H1</td><td >=MID(SUBSTITUTE(SUBSTITUTE(G1,",",REPT(" ",99),2),"=",REPT(" ",99),2),99,50)+0</td></tr></table></td></tr></table>
 

Watch MrExcel Video

Forum statistics

Threads
1,100,195
Messages
5,473,080
Members
406,845
Latest member
JohnR123

This Week's Hot Topics

Top