Hi, I have a list of location that I want in separated sheets.
Sheet name “Locations”
Number of locations: 21.
Macro I tried that is inspired from a answer on this site:
(looking at the preview, my code post will look horrible and I have no idea why or how to fix it)
Sub Main
Set thisBook = ThisComponent
locationsSheet = thisBook.Sheets.getByName("Locations")
i = 0
Do
c = locationsSheet.getCellByPosition(0, i)
REM // Stop creating sheets for locations once we find a
REM // row with no name.
If c.Type = com.sun.star.table.CellContentType.EMPTY Then
print "Exiting: Found row with no location name."
Exit Do
EndIf
locationName = c.String
sNew = thisBook.createInstance("com.sun.star.sheet.Spreadsheet")
thisBook.Sheets.insertByName(locationName, sNew)
i = i + 1
REM // Sanity-check on looping forever. We don't expect
REM // to have over 1000 locations.
Loop Until i > 300
End Sub
Error received when I run macro:
"BASIC runtime error
An exception occurred
Type: com.sun.uno.RunetimeException
Message: . "
Thread where I found the inspiring code. (I only change the variables)
Never ran a macro on calc before. Any help in understanding what I am doing wrong would be greatly appreciated!