Code: Select all
Sub Main
Dim ColPosition as Integer
Dim RowPosition as Integer
Dim Doc as Object
Dim SheetCopy as Object
Dim SheetPaste as Object
Dim CellCopy as Object
Dim CellPaste as Object
Dim Contents as String
Doc = ThisComponent 'sets Doc as the current spreedsheet
SheetCopy = Doc.Sheets.getByName ("Import") 'Assigns the Import sheet as the sheet to copy from
SheetPaste = Doc.Sheets.getByName ("Paste") 'Assigns the Paste sheet as the sheet to paste to
For RowPosition = 0 to 249 'count through the rows of the import sheet to
For ColPosition = 0 to 12 'count through the columns that need to be copied
CellCopy = SheetCopy.getCellByPosition (RowPosition, ColPosition) ' select cell to copy
Contents = Cstr(Cell) ' copy cell contects as string to contents variable
CellPaste = SheetPaste.getCellByPosition (RowPosition+2, ColPosition+5) 'select the cell to paste the copied info into
CellPaste.String = Contents 'paste the contents variable into the selected cell
Next ColPosition 'move to next column
Next RowPosition 'move to next row
End Sub
I'm also needing to create a button to attach it to. The module is called ImportOverwrite. I can create the button but need to know how to attach the module to the button so that it executes.
Any help is appreciated.
Title Edited to remove [OOoBasic]. Elements at the start of titles in square brackets have special meanings, like [Solved] or [Issue]. Better to re-word things as I have done for you. (TheGurkha, Moderator)