메인 컨텐츠로 가기

Excel에서 워크 시트 스크롤로 피벗 테이블 슬라이서를 계속 움직이는 방법은 무엇입니까?

피벗 테이블로 작업하는 동안 슬라이서를 삽입하여 테이블의 시각적 데이터를 필터링 할 수 있습니다. 이 기사에서는 워크 시트를 스크롤하는 동안 피벗 테이블 슬라이서를 항상 표시하는 방법에 대해 설명합니다.

VBA 코드로 워크 시트 스크롤을 사용하여 피벗 테이블 슬라이서를 계속 이동


VBA 코드로 워크 시트 스크롤을 사용하여 피벗 테이블 슬라이서를 계속 이동

다음 VBA 스크립트는 워크 시트와 함께 피벗 테이블 슬라이서를 계속 이동하는 데 도움이 될 수 있습니다. 다음과 같이하십시오.

1. 누르세요 다른 + F11 동시에 열려면 키 응용 프로그램 용 Microsoft Visual Basic 창.

2. 에서 응용 프로그램 용 Microsoft Visual Basic 창, 더블 클릭 이 워크북 왼쪽 프로젝트 창에서 아래 VBA 코드를 복사하여 붙여 넣습니다. ThisWorkbook (코드) 창문. 스크린 샷보기 :

VBA 코드 : 워크 시트 스크롤을 사용하여 피벗 테이블 슬라이서를 계속 이동

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. 누르세요 다른 + Q 닫는 키 응용 프로그램 용 Microsoft Visual Basic 창 대화 상자.

이제부터 워크 시트를 스크롤하는 동안 지정된 슬라이서가 활성 셀과 함께 이동합니다. 스크린 샷보기 :


관련 기사:

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 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