Skip i'r prif gynnwys

Sut i ychwanegu sawl maes yn y tabl colyn?

Pan fyddwn yn creu tabl colyn, mae angen i ni lusgo'r caeau i'r Row Labels neu'r Gwerthoedd â llaw fesul un. Os oes gennym restr hir o feysydd, gallwn ychwanegu ychydig o labeli rhes yn gyflym, ond dylid ychwanegu'r meysydd sy'n weddill at yr ardal Werth. A oes unrhyw ddulliau cyflym inni ychwanegu'r holl feysydd eraill i'r maes Gwerth gydag un clic yn y tabl colyn?

Ychwanegwch feysydd lluosog i mewn i faes Gwerth y tabl colyn gyda chod VBA


swigen dde glas saeth Ychwanegwch feysydd lluosog i mewn i faes Gwerth y tabl colyn gyda chod VBA

Yn anffodus, nid oes blwch gwirio i ni wirio'r holl feysydd yn Rhestr Maes Tabl Pivot yn gyflym gydag un clic, ond, gyda'r cod VBA canlynol, gall eich helpu i ychwanegu'r meysydd sy'n weddill i'r ardal Gwerthoedd ar unwaith. Gwnewch fel a ganlyn:

1. Ar ôl creu'r tabl colyn, yn gyntaf, dylech ychwanegu'r meysydd label rhes fel eich angen, a gadael y meysydd gwerth yn y Dewiswch feysydd i'w hychwanegu at yr adroddiad rhestr, gweler y screenshot: </ p>

doc-add-multip-fields-1

2. Daliwch i lawr y ALT + F11 allweddi i agor y Ffenestr Microsoft Visual Basic for Applications.

3. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Ffenestr Modiwl.

Cod VBA: Ychwanegu sawl maes i faes Gwerth tablau colyn mewn taflen waith weithredol

Sub AddAllFieldsValues()
'Update 20141112
    Dim pt As PivotTable
    Dim I As Long
    For Each pt In ActiveSheet.PivotTables
        For I = 1 To pt.PivotFields.Count
            With pt.PivotFields(I)
              If .Orientation = 0 Then .Orientation = xlDataField
            End With
        Next
    Next
End Sub

4. Yna pwyswch F5 yn allweddol i redeg y cod hwn, mae'r holl feysydd sy'n weddill wedi'u hychwanegu at yr ardal Gwerthoedd ar yr un pryd, gweler y screenshot:

doc-add-multip-fields-1

Nodyn: Mae'r cod VBA hwn yn cael ei gymhwyso i bob tabl colyn o daflen waith weithredol.


Erthyglau cysylltiedig:

Sut i restru'r holl dablau colyn o lyfr gwaith?

Sut i wirio a oes tabl colyn yn bodoli mewn llyfr gwaith?

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 (23)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am running this code. How much time does it take to complete? It's now 45 minutes it's still running. Please help me. By the way, my total field columns are 3600.
This comment was minimized by the moderator on the site
Hi, is there a way to add only the columns unseleted ones? thanks. 
This comment was minimized by the moderator on the site
Задача же не всегда стоит в получении списка, хочется допустим поправить названия таблиц или источников данных. Можете реализовать?
This comment was minimized by the moderator on the site
Is there a way to edit the macro that would send the fields into the rows label instead of the values?
This comment was minimized by the moderator on the site
If "Values are
"0" or "Null" how to suppress Row Values from Displaying

(ex. Sum of 2743 Difference)





Pivot "Rows"
Pivot "Values"





Row Labels





NP9 - Total Unexpended
Appropriations





Sum of OTHER Difference 1,045,355,165.31




Sum of 3200 Difference
0.00




Sum of 0108 Difference
12,873,630.29



Sum of 4586 Difference
(33,024,706.93)



Sum of 0148 Difference
(72,046,783.14)



Sum of 0129 Difference
(5,583,891.98)



Sum of 4598 Difference
(929,574.56)



Sum of 2743 Difference



Sum of 4041 Difference
0.00



Sum of 2799 Difference
This comment was minimized by the moderator on the site
Note: Che's error message:




Sub AddAllFieldsValues()




'Update 20141112



Dim
pt As PivotTable





Dim I As
Long





For Each
pt In ActiveSheet.PivotTables





For
I = 1 To pt.PivotFields.Count





End With







Next



Next




End Sub










Note: Che's trying to add the following
fields/snapshot- "Sum of OTHER Difference, Sum of 4096
Difference" over 80 fields to be
added







OTHER Difference



4096 Difference



4016 Difference
This comment was minimized by the moderator on the site
THANK YOU SO MUCH!!!
This comment was minimized by the moderator on the site
Thanks, helped me a lot
This comment was minimized by the moderator on the site
Works like a charm. Thanks
This comment was minimized by the moderator on the site
Hi.

It gives me a compile error when I click on Run

Please help
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