Here is an example of the macro that you desire. This takes the contents of a unique sheet called Source
and creates another sheet called Export
formatted roughly as you desire. I am reverse-engineering your source format, so undoubtedly this is imperfect. At a high level, the macro iterates down the first column of your sheet until it runs out of cells with something in them. When it finds a cell with a value, it iterates across the columns and reaches down a few rows as dictated by the source format, copying the source into rows as desired. A copy of the calc spreadsheet and macro also is available here.
Sub CopyMoveRows
shs = ThisComponent.Sheets
If shs.hasByName("Export") Then shs.removeByName("Export")
newSheet = ThisComponent.createInstance("com.sun.star.sheet.Spreadsheet")
shs.insertByName("Export", newSheet)
srcSheet = shs.getByName("Source")
x = 0
y = 0
cellFocus = srcSheet.getCellByPosition(x,y)
Do While Len(cellFocus.String) > 0
cellOutput = newSheet.getCellByPosition(x,y)
cellOutput.String = cellFocus.String
cellOutput.CharWeight = cellFocus.CharWeight
x = x + 1
cellFocus = srcSheet.getCellByPosition(x,y)
Loop
srcY = 1
srcX = 0
expRow = 1
CtEmpty = 0
Do While CtEmpty <= 8
srcX = 0
cellFirst = srcSheet.getCellByPosition(srcX,srcY)
If Len(cellFirst.String) > 0 Then
CtEmpty = 0
i = 1
RefDes = ""
Do While i <= 3
cellFocus = srcSheet.getCellByPosition(1,srcY + i)
RefDes = RefDes & cellFocus.String & " "
i = i + 1
Loop
i = 0
cellMfg = srcSheet.getCellByPosition(5,srcY)
Do While Len(cellMfg.String) > 0 And i <= 3
cellFocus = srcSheet.getCellByPosition(srcX,srcY)
Do While Len(cellFocus.String) > 0
cellOutput = newSheet.getCellByPosition(srcX,expRow)
cellOutput.String = cellFocus.String
srcX = srcX + 1
cellFocus = srcSheet.getCellByPosition(srcX,srcY)
Loop
cellOutput = newSheet.getCellByPosition(srcX,expRow)
cellOutput.String = RefDes
cellOutput = newSheet.getCellByPosition(5,expRow)
cellOutput.String = cellMfg.String
cellMfg = srcSheet.getCellByPosition(5, srcY + i)
expRow = expRow + 1
i = i + 1
srcX = 0
cellMfg = srcSheet.getCellByPosition(5, srcY + i)
Loop
Else
CtEmpty = CtEmpty + 1
End If
srcY = srcY + 1
Loop
End Sub
(if this answers your question, please accept the answer by clicking the check mark () to the left)