Hi, I am stuck working on a macro for my loan and credit card debit presentation. I have a learning disability and some dementia to aid in my problem-solving challenges and old knowledge of basic. I wish to display 6 to 10 accounts showing each month’s payments for each account. Accounts will have their own page. Using LibreOffice Calc 24 on windows 10 to make a data sheets with account information. A range of cells containing the account names will be the names for the following sheets made by my macro.
I downloaded a script from an AI, and it names my data sheet. It hangs up with a “basic runtime error object variable not set”, and does not create new sheets. I want it to create and name sheets for whatever is in my cell range. I have no idea what to do next so please help me.
My test data sheet has from a1 to a10 of 2 letter combinations for sheet names ab, cd, ef, etc… My macro looks like this:
sub NameSheetFromCellRange
dim osheet as object
dim oCellRange as object
dim I as integer
dim sSheetName as string
ThisComponent.getsSheets().getByIndex(0).getCellRangeByName(“a1:a10)
for i= 0 to oCellRange.getRows().getCount() - 1 ‘this line
sSheetName = oCellRange.getCellByPosition(i,0).getString()
if ThisComponent.getsSheets().hasByName(sSheetName) then
oSheet = ThisComponent.getSheets().getByIndex(i)
else
ThisComponent.getSheets().insertNewByName(sheetname, I)
end if
next i
end sub
I apologize for this repeat. My earlier attempts to log onto the site were unsuccessful. I’m catching up with things now.