Post by VITRIOLPost by martelloIn fondo anche le celle di una tabella sono indirizzate come le celle
di calc.
In Writer se divido la cella <A1> le celle diventano <A1> e <B1>, mentre
quella che era <B1> ora è <C1>.
C1
B2
B3
B4
.....
In un foglio di calcolo non credo che questo sia un comportamento
auspicabile, ma non saprei.
Ma se le cose sono fatte bene si può fare.
Prova questa macro in calc.
Public colonna,riga
sub DivisioneInVerticale
LeggiIndirizzoCellaAttiva
InserisciColonna (0,colonna+1)
i=0
while i<riga
uniscicelle(i,colonna,i,colonna+1)
i=i+1
wend
i=i+1
while i<1000
uniscicelle(i,colonna,i,colonna+1)
i=i+1
wend
end sub
'____________________________________________________________
Sub LeggiIndirizzoCellaAttiva
oSelectedCells = ThisComponent.CurrentSelection
oActiveCell = oSelectedCells.CellAddress
foglio=oActiveCell.sheet
colonna=oActiveCell.column
riga=oActiveCell.row
End sub
'*********************************************************
sub uniscicelle(riga1,colonna1,riga2,colonna2)
inizio=riga1+1
fine=riga2+1
col1=ColumnNumberToString(colonna1)
col2=ColumnNumberToString(colonna2)
ini=str(inizio)
ini=right(ini,len(ini)-1)
fin=str(fine)
fin=right(fin,len(fin)-1)
stra="$"+col1+"$"+ini+":$"+col2+"$"+fin
Merge(stra)
end sub
rem **************************************************************
function Merge (str)
Dim oCell 'Holds a cell temporarily
Dim oRange 'The primary range
Dim oSheet 'The fourth sheet
oSheet = ThisComponent.getSheets().getByIndex(0)
oRange = oSheet.getCellRangeByName(str)
oRange.merge(True)
End function
'************************************************
Function ColumnNumberToString(ByVal the_column As Long) As String
Dim s$
'Save this so I do NOT modify the parameter.
'This was an icky bug that took me a while to find
Do while the_column >= 0
s$ = Chr(65 + the_column MOD 26) + s$
the_column = the_column \ 26 - 1
Loop
ColumnNumberToString = s$
End Function
'_______________________________________________
Sub InserisciColonna (foglio,Colonna)
' Elimina la riga specificata
Doc = ThisComponent
Sheet = Doc.Sheets(foglio)
Sheet.Columns.InsertByIndex(colonna,1)
End Sub
'__