Skip i'r prif gynnwys

Sut i ddarganfod a chael gwerth y gell weladwy gyntaf ar ôl hidlo yn Excel?

Mewn rhai achosion, efallai y bydd angen i chi gael gwerth y gell weladwy gyntaf mewn rhestr wedi'i hidlo. Sut i'w gyflawni? Bydd yr erthygl hon yn dangos dulliau i chi ei datrys.

Darganfyddwch a chael gwerth y gell weladwy gyntaf ar ôl hidlo gyda fformiwla arae
Darganfyddwch a chael gwerth y gell weladwy gyntaf ar ôl hidlo gyda VBA


Darganfyddwch a chael gwerth y gell weladwy gyntaf ar ôl hidlo gyda fformiwla arae

Gallwch gymhwyso'r fformiwla arae ganlynol i gael gwerth y gell weladwy gyntaf mewn rhestr wedi'i hidlo. Gwnewch fel a ganlyn.

1. Dewiswch gell wag ar gyfer gosod y gwerth gweladwy cyntaf, rhowch y fformiwla isod i mewn iddi, ac yna pwyswch y Ctrl + Symud + Rhowch allweddi ar yr un pryd.

=INDEX(C2:C19,MIN(IF(SUBTOTAL(3,OFFSET(C2,ROW(C2:C19)-ROW(C2),0)),ROW(C2:C19)-ROW(C2)+1)))

Nodyn: Yn y fformiwla, C2: C19 yw'r rhestr wedi'i hidlo rydych chi am ddychwelyd y gwerth cell gweladwy cyntaf, C2 yw cell gyntaf y rhestr. Gallwch eu newid yn ôl yr angen.

Yna gallwch weld gwerth y gell weladwy gyntaf yn y rhestr wedi'i hidlo wedi'i phoblogi yn y gell a ddewiswyd fel y dangosir y screenshot uchod.


Darganfyddwch a chael gwerth y gell weladwy gyntaf ar ôl hidlo gyda VBA

Ar wahân i ddefnyddio'r fformiwla arae uchod i gael gwerth y gell weladwy gyntaf mewn rhestr wedi'i hidlo, gallwch redeg y sgript VBA isod i ddychwelyd cell weladwy gyntaf rhestr wedi'i hidlo yn gyflym. Gwnewch fel a ganlyn.

1. Dewiswch gell wag fel E8 ar gyfer gosod gwerth cell gweladwy cyntaf rhestr wedi'i hidlo.

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

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

Cod VBA: darganfyddwch a chael gwerth y gell weladwy gyntaf ar ôl hidlo yn Excel

Sub FirstVisibleCell()
   With Worksheets("Sheet1").AutoFilter.Range
       ActiveCell.Value2 = Range("C" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2
    End With
End Sub

Nodyn: Yn y cod, Sheet1 yw enw'r ddalen sy'n cynnwys y rhestr wedi'i hidlo. “C” yw'r enw colofn rydych chi am gael y gwerth gweladwy cyntaf ohono. Gallwch eu newid yn ôl yr angen.

3. Gwasgwch y F5 allwedd i redeg y cod, yna bydd y gell weladwy gyntaf o restr wedi'i hidlo sy'n lleoli yng ngholofn C yn cael ei phoblogi i gell E8 ar unwaith.

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 (18)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thanks a lot, that formula INDEX(C2:C19,MIN(IF(SUBTOTAL(3,OFFSET(C2,ROW(C2:C19)-ROW(C2),0)),ROW(C2:C19)-ROW(C2)+1))) literally save my soul.
Even though I still do not get how the formula works, it does provide the return that I would like to have.

Regards,
Vedat
This comment was minimized by the moderator on the site
Thank you!
This comment was minimized by the moderator on the site
In the following VBA code, can you please explain what does SpecialCells(xlCellTypeVisible)(1) mean? What is (1) used for after SpecialCells(xlCellTypeVisible)?
ActiveCell.Value2 = Range("C" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2
This comment was minimized by the moderator on the site
Can you help me write this formula in google sheet with arrayformula ()

{=INDEX(C2:C19,MIN(IF(SUBTOTAL(3,OFFSET(C2,ROW(C2:C19)-ROW(C2),0)),ROW(C2:C19)-ROW(C2)+1)))}
This comment was minimized by the moderator on the site
So for me the answer above simply does't work that well. I have a workbook with over 23k rows and is something I've been working to optimize over the years. My solution came to me this morning in yet another spark of inspiration.
Assuming that you are using a TABLE to get the data you want do this:One row (I named it "Rownmbr") is dedicated to: =CELL([@[YOURFIRSTROW]])
Outside the table you make a formula somewhere:=INDIRECT(CONCATENATE("A";SUBTOTAL(105;Table1[Rownmbr])))
You simply replace the "A" with wherever you want to get the data from. For me this works great, and it's not a heavy formula to use that will bog down the document further.
This comment was minimized by the moderator on the site
This solution worked perfectly for me, since I was using a table. The instructions were hard to follow, so hopefully this explanation will be a bit clearer.
Say you have an excel table named "Table_Name."  First, create a new column in your table and name it "RowNumber". 
In that new column, enter the formula "=ROW([@RowNumber])" This will then populate the new column with
In the cell where you want to display the first visible value, enter the formula "=INDIRECT("A"&SUBTOTAL(105,Table_Name[RowNumber]))"  The "A" is the letter of the column that holds the value you want to return.
The SUBTOTAL(105,...) function returns the minimum value of all the visible rows in a given range, which in the case above will return the row number of the first visible row.
The INDIRECT function returns the value of the cell for a given cell address. This is why you need the first part of the formula to contain the column letter of the column you want to display. The second part of the formula will return the row number.


This comment was minimized by the moderator on the site
This formula works, but be aware that if you have blank cells, the formula can malfunction and select the first value in the entire table, not just in the filtered results. The workaround I found was to replace blank cells with NULL or a space.
This comment was minimized by the moderator on the site
First I had blanks.... then all cells were filled but still having the #VALUE response. Hopefully this formula works on text as well...! Thanks for the advise anyway ;-)
This comment was minimized by the moderator on the site
It works. Thanks so much...
This comment was minimized by the moderator on the site
Thanks a million🙏🌺
This comment was minimized by the moderator on the site
‌wonderful🌺 Thanks a million🙏
This comment was minimized by the moderator on the site
I keep getting a Run-time error '91' Object variable or With block variable not set. My worksheet is Sheet1 titled AllBrands. This is my formula :

Sub FirstVisibleCell()
With Worksheets("ALLBRANDS").AutoFilter.Range
ActiveCell.Value2 = Range("H" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2
End With

End Sub

Any help will be appreciated!
This comment was minimized by the moderator on the site
Unfortunately - neither the formula - that gives me a #VALUE error nor the VBA works for me giving me a run-time error '1004'
Too bad as I have Office 2019 and I was expecting one of these features to work when filtering specific cells... :-(
This comment was minimized by the moderator on the site
Hi Bub,
The code works well in my case. Which Excel version are you using?
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