Skip to main content

Conas carachtair nó focail dhúblacha a bhaint i sreangán cille?

Má cheaptar go bhfuil carachtair nó focail dhúblacha i ngach cill, agus gur mhaith leat na dúbailtí a bhaint agus gan ach carachtair nó focail uathúla a fhágáil. Conas a d’fhéadfá an fhadhb seo a réiteach in Excel?

Bain carachtair dhúblacha de shreang téacs le Feidhm Sainithe ag an Úsáideoir

Bain focail dhúblacha scartha le poncaíocht le Feidhm Sainithe ag an Úsáideoir


mboilgeog cheart gorm saighead Bain carachtair dhúblacha de shreang téacs le Feidhm Sainithe ag an Úsáideoir

Má tá liosta de shreangán téacs agat, anois, ní mór duit na carachtair dhúblacha a bhaint mar a leanas an pictiúr a thaispeántar. Anseo, is féidir liom labhairt faoi chód VBA chun déileáil leis.

doc-bain-dúblach-carachtair-1

1. Coinnigh síos an ALT + F11 eochracha a oscailt Fuinneog Microsoft Visual Basic for Applications.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Fuinneog an Mhodúil.

Cód VBA: Bain carachtair dhúblacha de shreangán téacs i gcill

Function RemoveDupes1(pWorkRng As Range) As String
'Updateby Extendoffice
Dim xValue As String
Dim xChar As String
Dim xOutValue As String
Set xDic = CreateObject("Scripting.Dictionary")
xValue = pWorkRng.Value
For i = 1 To VBA.Len(xValue)
    xChar = VBA.Mid(xValue, i, 1)
    If xDic.Exists(xChar) Then
    Else
        xDic(xChar) = ""
        xOutValue = xOutValue & xChar
    End If
Next
RemoveDupes1 = xOutValue
End Function

3. Ansin sábháil agus dún an cód seo, téigh ar ais chuig an mbileog oibre, agus cuir isteach an fhoirmle seo = removedupes1 (A2) (A2 an cill sonraí ar mhaith leat dúbailtí a bhaint aisti) i gcill bhán seachas do chuid sonraí, féach an scáileán:

doc-bain-dúblach-carachtair-1

4. Agus ansin tarraing an láimhseáil líonta chuig na cealla raon a theastaíonn uait an fhoirmle seo a chur i bhfeidhm, baineadh na carachtair dhúblacha go léir as gach cill láithreach.

doc-bain-dúblach-carachtair-1


mboilgeog cheart gorm saighead Bain focail dhúblacha scartha le poncaíocht le Feidhm Sainithe ag an Úsáideoir

Má tá focail áirithe ann atá scartha le marcanna poncaíochta áirithe i gcill, is féidir leat na focail dhúblacha a bhaint mar is mian leat. Déan na céimeanna seo a leanas le do thoil:

1. Coinnigh síos an ALT + F11 eochracha a oscailt Fuinneog Microsoft Visual Basic for Applications.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Fuinneog an Mhodúil.

Cód VBA: Bain focail dhúblacha scartha le poncaíocht cille

Function RemoveDupes2(txt As String, Optional delim As String = " ") As String
    Dim x
    'Updateby Extendoffice
    With CreateObject("Scripting.Dictionary")
        .CompareMode = vbTextCompare
        For Each x In Split(txt, delim)
            If Trim(x) <> "" And Not .exists(Trim(x)) Then .Add Trim(x), Nothing
        Next
        If .Count > 0 Then RemoveDupes2 = Join(.keys, delim)
    End With
End Function

3. Ansin sábháil agus dún an cód seo, filleadh ar an mbileog oibre, agus cuir isteach an fhoirmle seo = RemoveDupes2 (A2, ",") isteach i gcill bhán in aice le do chuid sonraí, féach an scáileán:

doc-bain-dúblach-carachtair-1

4. Ansin cóipeáil síos an fhoirmle chuig na cealla atá uait, agus baineadh na focail dhúblacha go léir as gach cealla. Féach an pictiúr:

doc-bain-dúblach-carachtair-1

nótaí: San fhoirmle thuas, A2 léiríonn sé an chill is mian leat a úsáid, agus seasann an camóg (,) don mharc poncaíochta a scarann ​​na focail i gcill, is féidir leat é a athrú go dtí aon phoncaíocht eile ar do riachtanas.

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (67)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How to remove duplicate words in excel template


Flooring|Tiles Flooring|Flooring|Vitrified Tiles|Tiles|Flooring|Tiles
This comment was minimized by the moderator on the site
Not sure if this thread is still alive. I am trying to use this for something as simple as what is shown in the chart above and I keep on receiving #NAME? error. Cell A2 has XXX, YYY, XXX, AAA I can't quite understand what I am doing wrong. I have the code in my personal workbook. Would that be the issue?
This comment was minimized by the moderator on the site
Thank you for the beautiful and useful coding. Can we do the same using Power Query?
This comment was minimized by the moderator on the site
Hi, is there a way to get the result of "RemoveDupes2" alphabetically sorted?
This comment was minimized by the moderator on the site
Hey! can anyone help me,
I have a data in excel example:



CARITAS, CSCED, FREE, NRC
BOSADP, DHCBI
BOSADP, Mercy Corps, NRC
ADRA, NRC
BOSADP, CAID
AAH, FAO (NEYIF), CRS (NEYIF)
SWNI, Mercy Corps,
CARE, PLAN, NRC
Mercy Corps, NRC
BOSADP, DHCBI, GREENCODE, NRC, AAH BOSADP


What I really want

CARITAS
BOSADP
DHCBI
NRC
ADRA
CAID
AAH
FAO
NEYIF
CRS
SWNI
CARE
PLAN
Mercy Corps
GREENCODE
FREE


the repeated words separated by comma deleted and and those that not repeated but separated by comma move to the next columns
This comment was minimized by the moderator on the site
Hey! can anyone help me,
I have a data in excel example:



CARITAS, CSCED, FREE, NRC
BOSADP, DHCBI
BOSADP, Mercy Corps, NRC
ADRA, NRC
BOSADP, CAID
AAH, FAO (NEYIF), CRS (NEYIF)
SWNI, Mercy Corps,
CARE, PLAN, NRC
Mercy Corps, NRC
BOSADP, DHCBI, GREENCODE, NRC, AAH BOSADP


What I really want

CARITAS
BOSADP
DHCBI
NRC
ADRA
CAID
AAH
FAO
NEYIF
CRS
SWNI
CARE
PLAN
Mercy Corps
GREENCODE
FREE


the repeated words separated by comma deleted and and those that not repeated but separated by comma move to the next columns
This comment was minimized by the moderator on the site
i tried applying method2 to numbers but it does not work. eg. 1104, 1104, 203, 203, 409, 409 >>>1104, 203, 409 How do you get method 2 to work with numbers?
This comment was minimized by the moderator on the site
Hello, deezy,
The second method works well for numbers, please see the below screenshot.
Please try it again, thank you!
This comment was minimized by the moderator on the site
Thanks so much for sharing knowledge, I used the "Remove Duplicate Words Separated By Punctuation With User Defined Function" and it worked great. May you knowledge grow and grow.
This comment was minimized by the moderator on the site
how about to remove duplicate character with an exception

for example from MMMPXLL, i want to remove M but keep the L

so the result will be MPXLL
This comment was minimized by the moderator on the site
Edit :

some problem solved with removedupes2, but i have to do it one by one

for example i cant remove duplicate letter y,a,l at once. I have to do it one by one.

also, for case there is data like this yyypl, it become pl, the "y" is totally removed
This comment was minimized by the moderator on the site
i have a string of text like so

1 Ser 1 Ser 1 Ser 1 Ser 1 Ser 1 Ser 1 Ser 1 Ser 1 Ser 2 Ser 2 Ser 2 Ser 2 Ser 2 Ser 2 Ser 2 Ser 2 Ser 3 Ser 3 Ser 3 Ser 3 Ser 3 Ser 3 Ser 3 Ser 3 Ser X3 X5

when applying remove dupes 2 i get

1 Ser 2 3 X3 X5


by the looks of it, all duplicates except the first instance are kept, is there any way to tweek this so all duplicate instances except the last occurance are kept ?

so my desired outcome would be

1 2 3 Ser X3 X5

thank you in advanced!
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