Copy data with macro

This is my first visit to the forum and I greet you very much!

I desperately need your help!

I would like to insert cells A23 - Q23 from a spreadsheet into a new spreadsheet.


02/27/2024…Flour…Eggs…Baking powder…Milk…60 min…Cake…1 kg…etc.

The data is located in spreadsheet 1, in cells A23 - Q23

The data should be inserted into spreadsheet 2 (cells A2 - Q2).
If there is already data in there, the data should be in the ones underneath
Area can be inserted (cells A3 - Q3).

The data should be copied over using a button in spreadsheet 1.
I have already created the button, but I am missing a macro for the button.

Can an expert help me?

Thanks alot!

I’m not entirely sure that I understand where to copy this range - to another sheet of the same spreadsheet or to another spreadsheet? Maybe one of the macros from Chapter 5.23. Manipulating the clipboard will work for you?

Thank you very much for your help. Mr JohnSUN!

And my thanks go to Mikele! Mikele sent me the right approach! I can easily adapt this code snippet to my needs.

I’m leaving the Python code here to help others too!

def copy_area():
    oDoc = XSCRIPTCONTEXT.getDocument()
    oTab1 = oDoc.Sheets.getByName("Spreadsheet3")
    oBereich = oTab1.getCellRangeByName('A23:Q23')
    oTab2 = oDoc.Sheets.getByName("Spreadsheet4")

Thank you very much for the help! :wink:

You can used copyRange too, look: