Ryan Camick
Ryan Camick

Reputation: 19

Filter in OpenOffice Calc

Scenario:

I have a spreadsheet with info from a giveaway campaign in which I get paid per new Twitter follow my client receives through my campaign. Unfortunately the application I use does not track new followers vs existing ones because they offer an entry for new and existing followers for the "Follow on Twitter for 1 Entry". Because I also offer other means to gain entries I need to export the data and filter the results to show only those who've gained an entry on the Twitter Follow and then filter out those who are new vs existing by means of a separate application.

Problem:

There should be a separate column for each data type; name,email,action, etc. The action column is where I would expect to find the "Follow On Twitter" but the file is very disorganized and the action can be found in many different columns. Therefore I need a way to show only the rows in which there is a field with "Follow on Twitter". I am at a loss to try and figure out how to do this.

Upvotes: 1

Views: 227

Answers (1)

szd
szd

Reputation: 106

The following macro will search for "Follow On Twitter" in each cell. For each row, if a match is found, the row will be shown, else it will be hidden. You will have to adjust the macro to match your sheet's total number of rows/columns.

Sub Dummy()
    GlobalScope.BasicLibraries.LoadLibrary("Tools")

    Dim ActiveSheet As Object
    ActiveSheet = ThisComponent.CurrentController.ActiveSheet

    Dim r,c As Integer
    For r = 0 To 25
        Dim found As Boolean
        found = False
        For c = 0 to 10
            Dim cell As Object
            cell = ActiveSheet.getCellByPosition(c, r)
            If cell.String = "Follow On Twitter" Then
                found = True
                Exit For
            End If
        Next c
        Dim row As Object
        row = ActiveSheet.getRows.getByIndex(r)
        row.IsVisible = found
    Next r
    MsgBox "Done"
End Sub

Upvotes: 3

Related Questions