How to delete specific columns with a Macro?

I have to work with spreadsheet everyday that I export from an another system, and my first operation is always to delete the columns I don’t need (for instance: A, B, E, G, H, I, J, N).

Is there a way to save or script a Macro to execute that operation with a single keystroke?
This way, I wouldn’t need to select every column and delete them manually.

Thanks for you help!

RFO

same situation here
can you pls tell me how to remove particular columns from sheet through macro code

By John

Sub DelColumn
    Dim oSheets As Variant
    Dim oSheet As Variant
    Dim oColumns As Variant
    
            oSheets = ThisComponent.getSheets()     ' All sheets of this workbook
            oSheet = oSheets.getByName("Sheet1")    ' One sheet with name "Sheet1" (for example)
            oColumns = oSheet.getColumns()  ' All columns of this sheet as object (with some metods)
    
            oColumns.removeByIndex(1, 3)    ' Remove 3 columns from B (B-C-D)
            oColumns.removeByIndex(6, 1)    ' Remove one column (now it is column G - 6th)
    End Sub

Thnks John

There is a nice answer given here by F3K Total:
https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=86812
He includes a working example, and it still works with current versions of Libre Office.

Const SColumns = "A,C,E,F,H,K,L" 'ascending

Sub S_DELETE_COLUMNS
    aColumns = Split(SColumns,",")
    oSheet = ThisComponent.CurrentController.ActiveSheet
    for i = uBound(aColumns) to 0 step -1
        oColumn = oSheet.Columns.getbyname(aColumns(i))
        oColumn.Columns.removebyindex(0,1)
    next i
End Sub