Extract Text Before Word "Golongan"

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
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
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]A[/COLOR]​
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]B[/COLOR]​
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]1[/COLOR]​
DATA/TEXTEXTRACT
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]2[/COLOR]​
Rumah Negara Golongan I Tipe C PermanenRumah Negara
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]3[/COLOR]​
Rumah Negara Golongan I Tipe B PermanenRumah Negara
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]4[/COLOR]​
Bangunan Gedung Kantor PermanenBangunan Gedung Kantor Permanen
[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]5[/COLOR]​
Pagar PermanenPagar Permanen

<tbody>
</tbody>
Sheet: Sheet1

<tbody>
</tbody>

anyone would help me..

m.susanto
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,216,079
Messages
6,128,687
Members
449,464
Latest member
againofsoul

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