انتقل إلى المحتوى الرئيسي

كيف تحافظ على تقطيع Pivot Table متحركًا مع تمرير ورقة العمل في Excel؟

أثناء العمل مع Pivot Table ، يمكنك إدراج مقسمات لتصفية البيانات بصريًا من الجدول. تتحدث هذه المقالة عن إبقاء أداة تقطيع Pivot Table مرئية دائمًا أثناء التمرير في ورقة العمل.

استمر في تحريك أداة تقطيع Pivot Table مع تمرير ورقة العمل باستخدام كود VBA


استمر في تحريك أداة تقطيع Pivot Table مع تمرير ورقة العمل باستخدام كود VBA

يمكن أن يساعدك البرنامج النصي VBA التالي في الحفاظ على أداة تقطيع Pivot Table تتحرك مع ورقة العمل. الرجاء القيام بما يلي.

1. اضغط على قديم + F11 مفاتيح في نفس الوقت لفتح ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

2. في ال ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، انقر مرتين ThisWorkbook في الجزء الأيسر من المشروع ، ثم انسخ والصق رمز VBA أدناه في ملف ThisWorkbook (كود) نافذة او شباك. انظر لقطة الشاشة:

رمز VBA: حافظ على تحريك أداة تقطيع Pivot Table مع تمرير ورقة العمل

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

ملاحظة:

1). في الكود ، Column1 و Column2 هما أسماء تقطيع الشرائح.

2). يمكنك تحديد موضع القواطع أثناء التمرير في ورقة العمل في الكود.

3). ويمكنك إضافة المزيد من تقطيع الشرائح إلى الكود أو إزالة أدوات التقطيع منه حسب حاجتك.

3. اضغط على قديم + Q مفاتيح لإغلاق ميكروسوفت فيسوال باسيك للتطبيقات مربع حوار النافذة.

من الآن فصاعدًا ، سيتم نقل مقسمات العرض المحددة مع الخلية النشطة أثناء التمرير في ورقة العمل. انظر لقطة الشاشة:


مقالات ذات صلة:

أفضل أدوات إنتاجية المكتب

🤖 مساعد Kutools AI: إحداث ثورة في تحليل البيانات على أساس: التنفيذ الذكي   |  إنشاء التعليمات البرمجية  |  إنشاء صيغ مخصصة  |  تحليل البيانات وإنشاء الرسوم البيانية  |  استدعاء وظائف Kutools...
الميزات الشعبية: البحث عن التكرارات أو تمييزها أو تحديدها   |  حذف الصفوف الفارغة   |  دمج الأعمدة أو الخلايا دون فقدان البيانات   |   جولة بدون صيغة 
سوبر بحث: معايير متعددة VLookup    VLookup ذات القيمة المتعددة  |   VLookup عبر أوراق متعددة   |   بحث غامض ....
قائمة منسدلة متقدمة: إنشاء القائمة المنسدلة بسرعة   |  القائمة المنسدلة التابعة   |  قائمة منسدلة متعددة التحديد ....
مدير العمود: إضافة عدد محدد من الأعمدة  |  نقل الأعمدة  |  تبديل حالة رؤية الأعمدة المخفية  |  مقارنة النطاقات والأعمدة 
الميزات المميزة: التركيز على الشبكة   |  عرض تصميم   |   شريط الفورمولا الكبير    مدير المصنفات والأوراق   |  مكتبة الموارد (النص السيارات)   |  منتقي التاريخ   |  اجمع أوراق العمل   |  تشفير/فك تشفير الخلايا    إرسال رسائل البريد الإلكتروني عن طريق القائمة   |  سوبر تصفية   |   مرشح خاص (تصفية غامق / مائل / يتوسطه خط ...) ...
أفضل 15 مجموعة أدوات12 نص الأدوات (إضافة نص, إزالة الأحرف، ...)   |   +50 رسم الأنواع (مخطط جانت، ...)   |   40+ عملي الصيغ (احسب العمر على أساس تاريخ الميلاد، ...)   |   19 إدخال الأدوات (أدخل رمز الاستجابة السريعة, إدراج صورة من المسار، ...)   |   12 تحويل الأدوات (أرقام إلى كلمات, نتيجة تحويل عملة، ...)   |   7 دمج وتقسيم الأدوات (الجمع بين الصفوف المتقدمة, تقسيم الخلايا، ...)   |   ... و اكثر

عزز مهاراتك في Excel باستخدام Kutools for Excel، واختبر كفاءة لم يسبق لها مثيل. يقدم Kutools for Excel أكثر من 300 ميزة متقدمة لتعزيز الإنتاجية وتوفير الوقت.  انقر هنا للحصول على الميزة التي تحتاجها أكثر...

الوصف


يجلب Office Tab الواجهة المبوبة إلى Office ، ويجعل عملك أسهل بكثير

  • تمكين التحرير والقراءة المبوبة في Word و Excel و PowerPointوالناشر والوصول و Visio والمشروع.
  • فتح وإنشاء مستندات متعددة في علامات تبويب جديدة من نفس النافذة ، بدلاً من النوافذ الجديدة.
  • يزيد من إنتاجيتك بنسبة 50٪ ، ويقلل مئات النقرات بالماوس كل يوم!
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