Page 1 of 1

Macro workaround for transferring tags between databases

PostPosted: Sun Jan 31, 2021 9:37 pm
by mythrilfox
hey all, I was looking for a way to transfer tags between databases so I could go over tagged hands later in my hole-cards-revealed database. this isn't quite that, but I came up with a spreadsheet macro workaround that's almost as good and only takes a couple of seconds. thought I'd share the idea here in case anyone else could use it.

basically you bring up the tagged hands in your main database, run "Export Report", and then run the macro on the report. the macro creates an expression filter that filters for all of the hands you have listed. switch to the hole cards DB, apply the expression, and voila.

Code: Select all
Sub HandFilter()

Dim Doc As Object
dim Cell as object
dim i as integer
dim filter as string
dim Sheet as object

Doc = ThisComponent
Sheet = Doc.CurrentController.ActiveSheet

Cell = Sheet.getCellByPosition(0,1)
filter = "#Hand ## = '" & Cell.String & "'"

i = 2
Cell = Sheet.getCellByPosition(0,i)

while Cell.Type <>
   filter = filter & " OR #Hand ## = '" & Cell.String & "'"
    i = i+1
    Cell = Sheet.getCellByPosition(0,i)

Cell = Sheet.getCellByPosition(0,i+1)
Cell.String = filter

End Sub

this is for Libreoffice Calc, but I'm sure it could be modded for Excel pretty easily. hth!