문제

자동 정렬하는 데이터가 수직으로,그러나 내가 원하는 행을 필터링 수 있습니다.말할 수 있습니다 나는 다음과 같은 테이블:

1 2 2 1 2

B E F F

B D E F F

C D E F F

내가 무엇을 할 수 있을 설정하려면 필터 및 여과기 행만 포함하는"B"첫 번째 열에 있습니다.내가 무엇을 하고 싶은 행만 포함하는"2"(이 경우 행은 두 번째,세 번째와 마지막 이 경우).

내가 찾는 일부에 관한 정보를 이 문제입니다.의 모든 답변을 발견했는 일부를 포함하는 매크로는 작업을 수행하지만,그들은 작성되었 MS Excel,와 호환되지 않습 OpenOffice

예를 들어,이 매크로를 얻어야 한 행 필터링 된,그러나이에서 작동하지 않는 OpenOffice Calc:

Option Explicit

Sub horizontal_filter()
'Erik Van Geit
'060910

Dim LC As Integer           'Last Column
Dim R As Long
Dim i As Integer
Dim FilterValue As String

Const FilterColumn = 1      '1 is most logical value but you may change this

R = ActiveCell.Row
LC = Cells(R, Columns.Count).End(xlToLeft).Column

FilterValue = Cells(R, FilterColumn)

Application.ScreenUpdating = False

'to filter starting after FilterColumn
For i = FilterColumn + 1 To LC
'to filter all columns even before the filtercolumn
'For i = 1 To LC
    If i <> FilterColumn Then
    Columns(i).Hidden = Cells(R, i) <> FilterValue
    End If
Next i

Application.ScreenUpdating = True

End Sub

어떤 도움은 대단히 감사합니다!

도움이 되었습니까?

해결책

할 수 없습니다,가정에서의 합리적인 비용입니다.그것은 훨씬 쉽게 데이터를 변환하는 행 얻을 열고 그 반대입니다.그래서,하게 변신한 데이터를 사용하여 Paste Special 와 함께 Transpose 옵션입니다.할 수 있도 이렇게 동적으로 사용하여 TRANSPOSE() 기능입니다.

편집:

지금 나는 그것을 가지고-당신이 원 열 숨기기 을 기반으로 특정 값입니다.이것이 가능한 매크로를 사용하 사실,그래서 내 처음 응답이었다 잘못된 미니다.거기에는 일부의 매크로 주위에는 이 작업을 수행하게 될 것입니다.결합할 수 있습니다 이러한 솔루션으로 자동 필터링합니다.기 솔루션 king_026 서 OpenOffice.org 포럼 (약간의 적응하는 테이블 구조-아래 참조):

REM  *****  BASIC  *****
sub hide
   rem ----------------------------------------------------------------------
   rem define variables
   dim document   as object
   dim dispatcher as object
   rem ----------------------------------------------------------------------
   rem get access to the document
   document   = ThisComponent.CurrentController.Frame
   dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

   rem get the current column
   nCol = ThisComponent.CurrentSelection.CellAddress.Column

   rem set the properties for moving right
   dim args2(1) as new com.sun.star.beans.PropertyValue
   args2(0).Name = "By"
   args2(0).Value = 1
   args2(1).Name = "Sel"
   args2(1).Value = false

   rem make thecurrent column counter
   dim cCol as integer
   CCol = 0

   rem goto the first column
   dim args1(0) as new com.sun.star.beans.PropertyValue
   args1(0).Name = "ToPoint"
   args1(0).Value = "$A$2"

   dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

   rem loop until you get back to the selected cell
    Do Until cCol > nCol

    rem hide if the cell value is 1
        if ThisComponent.CurrentSelection.string <> "" and ThisComponent.CurrentSelection.value = 1 then

            rem ----------------------------------------------------------------------
            dispatcher.executeDispatch(document, ".uno:HideColumn", "", 0, Array())

        End if

        rem goto the right nad increment the column counter
        dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args2())
        cCol = cCol + 1

    Loop

End sub

그래서,다음과 같은 테이블:

calc1

다음과 같이 보일 것입니다 후에는 자동 필터에 Col1 후 매크로았다는 그의 작품:

calc

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top