Skip i'r prif gynnwys

Sut i dynnu rhestr o werthoedd unigryw yn ddeinamig o ystod colofn yn Excel?

Ar gyfer amrediad colofn y mae'r gwerthoedd yn newid yn rheolaidd, ac mae angen i chi bob amser gael yr holl werthoedd unigryw o'r ystod ni waeth sut y newidiodd. Sut i wneud rhestr ddeinamig o werthoedd unigryw? Bydd yr erthygl hon yn dangos i chi sut i ddelio ag ef.

Tynnwch restr o werthoedd unigryw yn ddeinamig o ystod colofn gyda fformiwla
Tynnwch restr o werthoedd unigryw yn ddeinamig o ystod colofn gyda chod VBA


Tynnwch restr o werthoedd unigryw yn ddeinamig o ystod colofn gyda fformiwla

Fel y dangosir isod y llun, mae angen i chi dynnu rhestr o werthoedd unigryw yn ddeinamig o ystod B2: B9. Rhowch gynnig ar y fformiwla arae ganlynol.

1. Dewiswch gell wag fel D2, rhowch y fformiwla isod i mewn iddi a gwasgwch y Ctrl + Symud + Rhowch allweddi ar yr un pryd. (B2: B9 yw'r data colofn rydych chi am echdynnu'r gwerthoedd unigryw, D1 yw'r gell uchod lle mae'ch fformiwla wedi'i lleoli)

=IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$1:D1, $B$2:$B$9), 0)),"")

2. Daliwch i ddewis cell D2, yna llusgwch y Llenwch Trin i lawr i gael yr holl werthoedd unigryw o'r ystod benodol.

Nawr mae'r holl werthoedd unigryw yn ystod colofn B2: B9 wedi'u tynnu. Pan newidiodd gwerthoedd yn yr ystod hon, bydd y rhestr werth unigryw yn cael ei newid yn ddeinamig ar unwaith.

Dewis ac amlygu'r holl werthoedd unigryw yn hawdd mewn ystod o ragori:

Mae adroddiadau Dewiswch Gelloedd Dyblyg ac Unigryw cyfleustodau Kutools ar gyfer Excel yn gallu'ch helpu chi i ddewis ac amlygu'r holl werthoedd unigryw yn hawdd (cynnwys y dyblygu cyntaf) neu'r gwerthoedd unigryw sy'n ymddangos unwaith yn unig, yn ogystal â gwerthoedd dyblyg ag sydd eu hangen arnoch chi fel y dangosir isod.
Dadlwythwch Kutools ar gyfer Excel nawr! (llwybr am ddim 30 diwrnod)


Tynnwch restr o werthoedd unigryw yn ddeinamig o ystod colofn gyda chod VBA

Gallwch hefyd dynnu rhestr o werthoedd unigryw yn ddeinamig o ystod colofn gyda'r cod VBA canlynol.

1. Gwasgwch Alt + F11 allweddi ar yr un pryd i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Modiwlau. Yna copïwch a gludwch y cod VBA isod i'r Modiwlau ffenestr.

Cod VBA: Tynnwch restr o werthoedd unigryw o ystod

Sub CreateUniqueList()
Dim xRng As Range
Dim xLastRow As Long
Dim xLastRow2 As Long
Dim I As Integer
On Error Resume Next
Set xRng = Application.InputBox("Please select range:", "Kutools for Excel", Selection.Address, , , , , 8)
If xRng Is Nothing Then Exit Sub
On Error Resume Next
xRng.Copy Range("D2")
xLastRow = xRng.Rows.Count + 1
ActiveSheet.Range("D2:D" & xLastRow).RemoveDuplicates Columns:=1, Header:=xlNo
xLastRow2 = Cells(Rows.Count, "B").End(xlUp).Row
For I = 1 To xLastRow2
  If ActiveSheet.Range("D2:D" & xLastRow2).Cells(I).Value = "" Then
     ActiveSheet.Range("D2:D" & xLastRow2).Cells(I).Delete
  End If
Next
End Sub

Nodyn: Yn y cod, D2 yw'r gell y byddwch chi'n dod o hyd i'r rhestr werth unigryw. Gallwch ei newid yn ôl yr angen.

3. Ewch yn ôl i'r daflen waith, cliciwch Mewnosod > Siapiau > Petryal. Gweler y screenshot:

4. Tynnwch betryal yn eich taflen waith, yna nodwch rai geiriau y mae angen i chi eu harddangos arno. Yna cliciwch ar y dde a dewis Neilltuo Macro o'r ddewislen clicio ar y dde. Yn y Neilltuo Macro blwch deialog, dewiswch y CreuUniqueList yn y Enw macro blwch, ac yna cliciwch ar y OK botwm. Gweler y screenshot:

5. Nawr cliciwch ar y botwm petryal, a Kutools ar gyfer Excel blwch deialog yn ymddangos, dewiswch yr ystod sy'n cynnwys gwerthoedd unigryw y mae angen i chi eu tynnu, ac yna cliciwch ar y OK botwm.

O hyn ymlaen, gallwch ailadrodd y cam 5 uchod i ddiweddaru'r rhestr werth unigryw yn awtomatig.


Erthyglau perthnasol:

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 (35)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
con este procedimiento de filtro se hace de forma muy rapida

1.EN ESTE EJEMPLO los datos a remover los duplicados estan en la col A de la fila 59 a la 239
2. se define un criterio de filtrado en este caso en la fila d56 el mismo titulo de la lista a remover duplicados y la d57 la dejo en blanco
3. una vez ejecutado se muestran los datos en la fila destino, que en mi caso fue la d59

Range("A59:A239").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range _
("D56:D57"), CopyToRange:=Range("D59"), Unique:=True
This comment was minimized by the moderator on the site
I would like to be able to do this exact same thing, except using two separate column ranges (B2:B9) as well as (D2:D9) is this possible?
This comment was minimized by the moderator on the site
Hi Anthony,
You can place the results in the same column as the original data. Such as column B in this case.
But you need to reference the top cell of the result cell in the formula as follows.
=IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($B$11:B11, $B$2:$B$9), 0)),"") + Ctrl + Shift + Enter
This comment was minimized by the moderator on the site
Ik heb gemerkt dat de 'formule'-methode erg traag werkt bij grote datasets. Een goed alternatief is het gebruik van een draaitabel. Kies dan alleen de rijlabels, je krijgt dan een lijstje met unieke waarden. Het kan zijn dat je wat extra's krijgt "(leeg)" bijvoorbeeld. Je kunt deze er vervolgens uitfilteren. Helaas kun je maar op 1 criterium filteren. Ook daar zijn wel weer oplossingen voor, maar dat is wat complexer.
This comment was minimized by the moderator on the site
how to make the vba code work for a range where another formula was used?on column B I have a formula, referring to columns D and E.
If I use apply the code to column L (let's say), (obviously, properly modifying the cells in the code) the macro returns the formula applied to columns M and N... It works, then, but not as I want!How to keep the values in column B?thanks
This comment was minimized by the moderator on the site
thank you very much
This comment was minimized by the moderator on the site
I try the VBA Code and the formula. The code VBA is working very well but I can't keep a file with macro. But th problem is that I can't make the formula working. Did anybody have an idea ? Thank you
This comment was minimized by the moderator on the site
Hi Charlotte,
Thank you for your comment. You can keep the file with macro for future use by saving the workbook as an Excel Macro-Enabled Workbook.
For the formula problem, would you please provide a screenshot of your data? Thank you for your comment.
This comment was minimized by the moderator on the site
I'm using that =IFERROR(INDEX($B$2:$B$9, MATCH(0,COUNTIF($D$1:D1, $B$2:$B$9), 0)),"") formula which is great for one column but my data is spread across a range of columns and rows. Can I edit the formula to include the whole area? My data lives from AC4 to AR60...
This comment was minimized by the moderator on the site
Hi, thank you for your help.
Now, how can I have my values also sorted alphabetically? (I do not want to use the filter on my master table)
Should I use a COUNTIFS instead of COUNTIF?
Please HELP
This comment was minimized by the moderator on the site
Hi Alexis,
Sorry can't hep to sort the extracted value alphabetically at the same time with formula. Thank you for your comment.
This comment was minimized by the moderator on the site
I am trying to drag the formula down past my actual data so that I can input different sized data sets and not have to adjust anything. However, the last row after my actual data ends always returns a "0". I am using the unique values for something else in an adjacent column, and the 0 causes the last value to repeated (When I delete the 0 the value is no longer repeated). Any idea how to fix this? Also I am using Office 365 Business
This comment was minimized by the moderator on the site
If I do this for a thousand row excel sheet on the latest version of Excel on a Mac, it never returns. The first row works, but when I duplicate down, excel goes into a compute mode that has not returned values for over two hours now.

Any thoughts on how to do this for large lists (up to 2k rows) that will return 50 or 60 unique values?

I mocked this up in the "Numbers" app, and it's working perfectly there, taking only a couple minutes to calculate. It's just taking so long in Excel that I wonder if it will ever complete. I plan on letting it "run" overnight to see what will happen.
This comment was minimized by the moderator on the site
Check your Calculating options. It needs to be set to automatic. File > Options > Formulas > Calculating options > Workbook Calculation (Automatic selection)
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