Skip i'r prif gynnwys

Sut i dynnu llythrennau cyntaf o enwau yn Excel?

Pan fyddwch yn prosesu cofnodion cwsmeriaid neu'n uno post, gallai cael llythrennau cyntaf o enw penodol fod yn ddefnyddiol i chi, er enghraifft, HG ar gyfer Hal Greer. Felly dyma fi'n cyflwyno rhai triciau i chi dynnu llythrennau cyntaf o'r rhestr enwau yn Excel yn gyflym.

Tynnwch lythrennau cyntaf gyda fformiwla yn Excel

Mae llythrennau cyntaf dyfyniad yn defnyddio Swyddogaeth Diffiniedig yn Excel


swigen dde glas saeth Tynnwch lythrennau cyntaf gyda fformiwla yn Excel

Y dull cyntaf yw defnyddio fformiwla i dynnu llythrennau cyntaf o enwau yn Microsoft Excel.

Dewiswch gell wag, er enghraifft, Cell C2, teipiwch y fformiwla hon =LEFT(A2)&IF(ISNUMBER(FIND(" ",A2)),MID(A2,FIND(" ",A2)+1,1),"")&IF(ISNUMBER(FIND(" ",A2,FIND(" ",A2)+1)),MID(A2,FIND(" ",A2,FIND(" ",A2)+1)+1,1),"")(A2 yw cell gyntaf eich rhestr enwau), pwyswch Rhowch botwm, yna llusgwch yr handlen llenwi i lenwi'r amrediad. Nawr rydych chi'n gweld bod holl lythrennau blaen pob enw yn cael eu tynnu o'r rhestr enwau.


swigen dde glas saeth Mae llythrennau cyntaf dyfyniad yn defnyddio Swyddogaeth Diffiniedig yn Excel

Ar wahân i fformiwla, gallwch ddefnyddio'r Swyddogaeth Diffiniedig i dynnu llythrennau cyntaf o enwau penodol yn hawdd yn Microsoft Excel.

1. Dewiswch gell o'r golofn rydych chi am ei dewis a'i phwyso Alt + F11 i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y ffenestr naid, cliciwch Mewnosod > Modiwlau, yna gludwch y cod VBA canlynol i'r modiwl.

VBA: Tynnu llythrennau cyntaf o enwau

Function FirstCharacters(pWorkRng As Range) As String
'Updateby20140514
Dim arr As Variant
Dim xValue As String
Dim OutValue As String
xValue = pWorkRng.Value
arr = VBA.Split(Trim(xValue))
For i = 0 To UBound(arr)
    OutValue = OutValue & VBA.Left(arr(i), 1) & "."
Next
FirstCharacters = OutValue
End Function

3. Cadwch y cod a chau'r ffenestr, dewiswch gell wag a theipiwch y fformiwla hon = FirstCharacters (A2), yna pwyswch Rhowch botwm, a llusgwch yr handlen llenwi i lenwi'r ystod rydych chi ei eisiau. Ar ôl hynny, gallwch weld bod llythrennau cyntaf pob enw yn cael eu tynnu.

Tip: Gallwch chi newid y gwahanyddion "." o'r llythrennau cyntaf fel y mae eu hangen arnoch yn y VBA uchod.


Erthyglau Perthynas:

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (13)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello,
I need to extend this code to 4 initials, but I don’t understand how to extend it.

=LEFT(A2)&IF(ISNUMBER(FIND(" ",A2)),MID(A2,FIND(" ",A2)+1,1),"")&IF(ISNUMBER(FIND(" ",A2,FIND(" ",A2)+1)),MID(A2,FIND(" ",A2,FIND(" ",A2)+1)+1,1),"")

Please can you explain how to add another layer to this formula?
This comment was minimized by the moderator on the site
Hi, use the formula like this:
=LEFT(A2)&IF(ISNUMBER(FIND(" ",A2)),MID(A2,FIND(" ",A2)+1,1),"")&IF(ISNUMBER(FIND(" ",A2,FIND(" ",A2)+1)),MID(A2,FIND(" ",A2,FIND(" ",A2)+1)+1,1),"")&IF(ISNUMBER(FIND(" ",A2,FIND(" ",A2)+1)),MID(A2,FIND(" ",A2,FIND(" ",A2,FIND(" ",A2)+1)+1)+1,1),"")

About the explaination, it not few words can explan. You may know what the functions in the formula is used for what destination. If you want to learn the function, you can visit this site: https://www.extendoffice.com/excel/functions.html
This comment was minimized by the moderator on the site
Thank you so much. This worked perfectly.
This comment was minimized by the moderator on the site
If u need the prefix of Mr., Ms. or Mrs. can add it in the beginning as =LEFT(A2,SEARCH(" ",A2))&
This comment was minimized by the moderator on the site
Very good formula to get the initials from a name. But if the name contains with Mr., Ms. or Mrs. then this does not work. We have to separate put this prefix first. For that you can replace the A2 with TRIM(MID(A2,SEARCH(" ",A2)+1,100)) . So the formula will be as under
=LEFT(TRIM(MID(A2,SEARCH(" ",A2)+1,100)) )&IF(ISNUMBER(FIND(" ",TRIM(MID(A2,SEARCH(" ",A2)+1,100)) )),MID(TRIM(MID(A2,SEARCH(" ",A2)+1,100)),FIND(" ",TRIM(MID(A2,SEARCH(" ",A2)+1,100)) )+1,1),"")&IF(ISNUMBER(FIND(" ",TRIM(MID(A2,SEARCH(" ",A2)+1,100)),FIND(" ",TRIM(MID(A2,SEARCH(" ",A2)+1,100)) )+1)),MID(TRIM(MID(A2,SEARCH(" ",A2)+1,100)),FIND(" ",TRIM(MID(A2,SEARCH(" ",A2)+1,100)),FIND(" ",TRIM(MID(A2,SEARCH(" ",A2)+1,100)) )+1)+1,1),"")
This comment was minimized by the moderator on the site
Thank you for this!! I had been struggling with getting initials from a last name with a space or hyphen and was able to use this formula as-is, with the addition of another IF that searched for a hyphen. A huge relief!!
This comment was minimized by the moderator on the site
I used the formula above, but if the person does not put a space between their first / last name, how do you keep that from error out?
This comment was minimized by the moderator on the site
Amazing Thank you!
This comment was minimized by the moderator on the site
hi there
I Want to sort full name in to a new format if excel cell has text character more than 25 how to show it in initials and last name
Ex 01:- name has more than 25 characters
Full Name : Mildred Dresselhaus Lene Vestergaard Hau
Show as : M.D.L Vestergaard Hau
(it may add if more initials are ther for a long name)
Ex 02:-
Full Name : Enrico Fermi
Show as : Enrico Fermi
This comment was minimized by the moderator on the site
If the text contains more than 03 words
This comment was minimized by the moderator on the site
This works!!! Thank you!
This comment was minimized by the moderator on the site
Thank you! :lol: quite useful!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations