Skip to main content

Conas slicer de Tábla Pivot a choinneáil ag gluaiseacht le scrollaigh bileog oibre in Excel?

Agus tú ag obair le Pivot Table, féadfaidh tú slisní a chur isteach chun sonraí an tábla a scagadh go radhairc. Tá an t-alt seo ag caint ar slicer de Tábla Pivot a choinneáil le feiceáil i gcónaí agus an bhileog oibre á scrollú.

Coinnigh slicer de Tábla Pivot ag gluaiseacht le scrollaigh bileog oibre le cód VBA


Coinnigh slicer de Tábla Pivot ag gluaiseacht le scrollaigh bileog oibre le cód VBA

Is féidir leis an script VBA seo a leanas cabhrú leat slisní Tábla Pivot a choinneáil ag gluaiseacht le bileog oibre. Déan mar a leanas le do thoil.

1. Brúigh an Eile + F11 eochracha ag an am céanna chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cliceáil dúbailte An Leabhar Oibre seo sa phána Tionscadail ar chlé, agus ansin cóipeáil agus greamaigh an cód VBA thíos sa An Leabhar Oibre seo (Cód) fuinneog. Féach an pictiúr:

Cód VBA: Coinnigh slicer de Tábla Pivot ag bogadh le scrollaigh bileog oibre

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Dim ShF As Shape
    Dim ShM As Shape
    'specify a slicer
    Application.ScreenUpdating = False
    Set ShF = ActiveSheet.Shapes("Column1")
    Set ShM = ActiveSheet.Shapes("Column2")
    'change position of the slicer
    With Windows(1).VisibleRange.Cells(1, 1)
        ShF.Top = .Top
        ShF.Left = .Left + 300
        ShM.Top = .Top
        ShM.Left = .Left + 100
    End With
    Application.ScreenUpdating = True
End Sub

nótaí:

1). Sa chód, is iad Colún1 agus Colún2 ainmneacha na slisní.

2). Is féidir leat suíomh na slicers a shonrú agus tú ag scrollú an bhileog oibre sa chód.

3). Agus is féidir leat níos mó slicers a chur sa chód nó slicers a bhaint de mar is gá duit.

3. Brúigh an Eile + Q eochracha chun an Microsoft Visual Basic d’Fheidhmchláir bosca dialóige fuinneoige.

As seo amach, bogfar na slisní sonraithe leis an gcill ghníomhach agus iad ag scrollú an bhileog oibre. Féach an pictiúr:


Earraí gaolmhara:

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 (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Okay, so the title says "How To Keep Slicer Of Pivot Table Moving With Worksheet Scrolling In Excel?", but this VBA code only does it for the current selected cell, how can we do it for the scrolling of the workbook, and not just the selected cell?
This comment was minimized by the moderator on the site
I have 4 slicers which have been grouped together by selecting all 4 and the right clicking to use the group command.

Is it possible to assign this VBA by a group? How do you label the group and write the VBA to recognize it as one?
This comment was minimized by the moderator on the site
Hi Michael,
Sorry can't help with this. Thanks for your comment.
This comment was minimized by the moderator on the site
What does the first row indicate and how do we customize it to suit our slicer?
I'm very confused about that on basically every line.
This comment was minimized by the moderator on the site
Dear Katie
I don't know if I totally understand your question.
As I mentioned in above Notes, you need to replace Column1 and Column2 with the names of your slicers in the code in order to keep your slicer scrolling with the worksheet.
This comment was minimized by the moderator on the site
Hi,
Thank you for this VBA.

I have absolutely no idea about VBA and hence my question.

I used this VBA and I had a question.
How can i alter this VBA so that it works only for one sheet.

Right now, I have 8 sheets and every time i go to another sheet, it fails and asks me to end or debug.
I have done exactly the way as shown above.


This is my VBA here..
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim ShF As Shape
Dim ShM As Shape
'specify a slicer
Application.ScreenUpdating = False
Set ShF = ActiveSheet.Shapes("Client 1")
Set ShM = ActiveSheet.Shapes("Reminder 1")
'change position of the slicer
With Windows(1).VisibleRange.Cells(1, 1)
ShF.Top = .Top + 2
ShF.Left = .Left + 475
ShM.Top = .Top + 180
ShM.Left = .Left + 475
End With
Application.ScreenUpdating = True
End Sub


Please help.
This comment was minimized by the moderator on the site
Dear John,
Shift to the worksheet you want the VBA code only work for, then right click the Sheet tab and select View Code from the context menu.
And then copy and paste below VBA code into the opening Code window. See below screenshot:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ShF As Shape
Dim ShM As Shape
'specify a slicer
Application.ScreenUpdating = False
Set ShF = ActiveSheet.Shapes("Fruit")
Set ShM = ActiveSheet.Shapes("Sale")
'change position of the slicer
With Windows(1).VisibleRange.Cells(1, 1)
ShF.Top = .Top
ShF.Left = .Left + 300
ShM.Top = .Top
ShM.Left = .Left + 100
End With
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hi,I have updated my code as you have indicated. The slicer no longer scrolls along with the window however if I click in a new cell then the slicer will move. Is this the correct behavior?
This comment was minimized by the moderator on the site
Dear Crystal,

Thank you so very much for the code.
I did exactly as you said and it works like a charm.

Really appreciate it.
Cheers :)
This comment was minimized by the moderator on the site
Hi,
Thank you for this VBA.

I have absolutely no idea about VBA and hence my question.

I used this VBA and I had a question.
How can i alter this VBA so that it works only for one sheet.

Right now, I have 8 sheets and every time i go to another sheet, it fails and asks me to end or debug.
I have done exactly the way as shown above.


This is my VBA here..
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim ShF As Shape
Dim ShM As Shape
'specify a slicer
Application.ScreenUpdating = False
Set ShF = ActiveSheet.Shapes("Client 1")
Set ShM = ActiveSheet.Shapes("Reminder 1")
'change position of the slicer
With Windows(1).VisibleRange.Cells(1, 1)
ShF.Top = .Top + 2
ShF.Left = .Left + 475
ShM.Top = .Top + 180
ShM.Left = .Left + 475
End With
Application.ScreenUpdating = True
End Sub


Please help.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations