I wrote a VBA for excel to copy the last row of all csv-tables in one selected folder to a single excel sheet to compare them without opening every csv-table separately. Unfortunately, I noticed that I have to use libre office and therefore hoped to get LibreOffice to execute the VBA after I enabled the VBA support option. Then I run the VBA within LibreOffice it just opens all the csv-tables and closes them again. May someone with some experience in coding macros in LibreOffice tell me how I have to change the code to get the desired behaviour? In the following the VBA code and an image of how the result should look like:
Thank you so much for your help!
Rem Attribute VBA_ModuleType=VBAModule Option VBASupport 1 Sub Merge() Dim TargetTable As Object Dim SourceTable As Object Dim Path As String Dim file As String Dim lastRow As Long Dim SourceRng As Range Dim lastRowTgt As Long Dim sheetName As String Application.ScreenUpdating = False Application.DisplayAlerts = False Set TargetTable = ActiveWorkbook 'open workbook is target Path = InputBox("Enter Path", "Path") 'enter Path into Box file = Dir(CStr(Path & "*.csv*")) 'all files in csv-format Do While file <> "" 'do as long until all files are done Set SourceTable = Workbooks.Open(Path & file, False, True) 'open only as readable sheetName = Left(file, Len(file) - 4) With SourceTable.Sheets(sheetName) lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row 'assumes column 1 is contiguous Set SourceRng = .Range("A" & lastRow & ":AJ" & lastRow) End With With TargetTable.Sheets("Merge.xlsm") lastRowTgt = .Cells(.Rows.Count, 1).End(xlUp).Row 'assumes column 1 is contiguous SourceRng.Copy .Cells(lastRowTgt + 1, 1) End With SourceTable.Close file = Dir() Loop Application.ScreenUpdating = True Application.DisplayAlerts = True MsgBox "Files have been merged!" Set TargetTable = Nothing Set SourceTable = Nothing End Sub