Potrzebuję wyeksportować do pliku zakres komórek np: T2:V100 ale tylko wiersze w których A1:A100 są niepuste lub większe od 0 (nie ma to znaczenia).
Znalazłem skrypt jak poniżej. Czy da się go zmodyfikować do moich potrzeb aby filtrował wynik eksportu?
Kod: Zaznacz cały
Sub CreateCSVFile
Dim sURLFolder as String
Dim sFileName As String
Dim i As Integer
Dim n As Integer
Dim oSheet
Dim oCell
Dim oRange
Dim CellContentArray
REM Get the active sheet object
oSheet = ThisComponent.getCurrentController.ActiveSheet
REM Get the cell contents
oRange = oSheet.getCellRangeByPosition(19,1,21,99)
CellContentArray = oRange.getDataArray()
REM Get the filename from cell M1 (column 12, row 0) of the active sheet
oCell = oSheet.getCellByPosition(12,0)
REM Get the folder name this file is saved in and append the filename
sURLFolder=replace(ThisComponent.url,ThisComponent.title,"")
sFileName = sURLFolder & oCell.getString() & "eksport.csv"
REM Create a new file (if this filename exists, it will be deleted and replaced)
n = FreeFile()
Open sFileName For Output As #n
REM Write the contents of the data array to the file
REM This assumes all rows are six cells wide
For i = 0 To UBound(CellContentArray)
Print #n, CellContentArray(i)(0), CellContentArray(i)(1), CellContentArray(i)(2)
Next
REM Close the file
Close #n
End Sub