Extract Text Before Word "Golongan"

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,089
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all..

i have problem, how to extract text before word "Golongan"
like this

Excel 2007 32 bit
[TABLE="class: head"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=888888]#888888[/URL] "]
[TH][/TH]
[TH]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]A[/COLOR]​
[/TH]
[TH]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]B[/COLOR]​
[/TH]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=888888]#888888[/URL] "]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]1[/COLOR]​
[/TD]
[TD]DATA/TEXT[/TD]
[TD]EXTRACT[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=888888]#888888[/URL] "]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]2[/COLOR]​
[/TD]
[TD]Rumah Negara Golongan I Tipe C Permanen[/TD]
[TD]Rumah Negara[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=888888]#888888[/URL] "]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]3[/COLOR]​
[/TD]
[TD]Rumah Negara Golongan I Tipe B Permanen[/TD]
[TD]Rumah Negara[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=888888]#888888[/URL] "]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]4[/COLOR]​
[/TD]
[TD]Bangunan Gedung Kantor Permanen[/TD]
[TD]Bangunan Gedung Kantor Permanen[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=888888]#888888[/URL] "]
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]5[/COLOR]​
[/TD]
[TD]Pagar Permanen[/TD]
[TD]Pagar Permanen[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid"]
<tbody>[TR]
[TD]Sheet: Sheet1[/TD]
[/TR]
</tbody>[/TABLE]

anyone would help me..

m.susanto
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Here is another formula that you can try...

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

Note: One difference between my formula and the one admiral100 posted appears when A1 is blank... my formula displays nothing for it whereas admira100's formula displays 0.
 
Upvote 0
Here is another formula that you can try...

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

Note: One difference between my formula and the one admiral100 posted appears when A1 is blank... my formula displays nothing for it whereas admira100's formula displays 0.
Rick can you please let me know why did you add "golongan" with A1 for finding the same? If we don't do the same thus it will retrieve result.
 
Upvote 0
It's probably better not to be case sensitive here:

=IFERROR(LEFT(A1,SEARCH("Golongan",A1&"Golongan")-1),A1)

as you would not want to miss any golongan.

@Aladin can you please let me know why did you add "golongan" with A1 for finding the same? If we don't do the same thus it will retrieve result.
 
Upvote 0
Rick can you please let me know why did you add "golongan" with A1 for finding the same? If we don't do the same thus it will retrieve result.
It allows me to eliminate the IFERROR function call. The reason for the IFERROR is to protect against the error the FIND function generates when it cannot find the text it is looking for... by concatenating the word onto A1, it guarantees the FIND function will always find it. If the searched for text exists in the cell, FIND will find it first... but if the searched for text is not in the cell, FIND will find the one I added at the end and use that to return the full contents of the cell (what your examples indicated you wanted).



It's probably better not to be case sensitive here:

=IFERROR(LEFT(A1,SEARCH("Golongan",A1&"Golongan")-1),A1)

as you would not want to miss any golongan.
Since you did like I did and concatenated the the word onto A1 inside the SEARCH function, what error is the IFERROR protecting against?
 
Last edited:
Upvote 0
It allows me to eliminate the IFERROR function call. The reason for the IFERROR is to protect against the error the FIND function generates when it cannot find the text it is looking for... by concatenating the word onto A1, it guarantees the FIND function will always find it. If the searched for text exists in the cell, FIND will find it first... but if the searched for text is not in the cell, FIND will find the one I added at the end and use that to return the full contents of the cell (what your examples indicated you wanted).




Since you did like I did and concatenated the the word onto A1 inside the SEARCH function, what error is the IFERROR protecting against?

Thank you @Rik
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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