If my open my origianlly created excel file with Libreoffice macros disappear, anyway i can get this to work?
'========>>
Option Explicit
Public Const sBilancio_di_Apertura As String = "C3:D3"
Public Const sColonna_Entrata As String = "C:C"
Public Const sStr As String = "CHIUSURA DEL GIORNO"
Public Const sNome_Primo_Foglio As String = "1-10" '<<=== Modifica
'-------->>
Public Sub Update_Subsequent_Sheets(mySH As Worksheet)
Dim WB As Workbook
Dim SH As Worksheet
Dim i As Long, iIndex As Long
Dim rBilancio_di_Apertura As Range
Dim rCaption As Range, rChiasura_del_Giorno As Range
Dim dBilancio As Double
Set WB = ThisWorkbook
iIndex = mySH.Index
For i = iIndex + 1 To WB.Sheets.Count - 1
Set SH = WB.Sheets(i)
With SH
If IsNumeric(SH.Name) Or SH.Name = sNome_Primo_Foglio Then
Set rBilancio_di_Apertura = .Next.Range(sBilancio_di_Apertura)
With .Columns(sColonna_Entrata)
Set rCaption = .Offset(0, -1).Find(What:=sStr, After:=.Offset(0, -1).Cells(1), LookIn:= _
xlFormulas2, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)
End With
Set rChiasura_del_Giorno = rCaption.Offset(0, 1).Resize(1, 2)
dBilancio = Application.Sum(rChiasura_del_Giorno.Value)
With rBilancio_di_Apertura
.ClearContents
If rChiasura_del_Giorno.Cells(1) = "" Then
.Cells(2).Value = dBilancio
Else
.Cells(1).Value = dBilancio
End If
End With
End If
End With
Next i
End Sub
'--------->>
Public Function LastRow(SH As Worksheet, _
Optional Rng As Range, _
Optional minRow As Long = 1)
If Rng Is Nothing Then
Set Rng = SH.Cells
End If
On Error Resume Next
LastRow = Rng.Find(What:="*", _
After:=Rng.Cells(1), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
If LastRow < minRow Then
LastRow = minRow
End If
End Function
'<<========
Ctrl+R per accedere alla finestra Project Explorer ('Gestione progetti')
Fai doppio clic sul modulo ThisWorkbook (Questa_cartella_di_Lavoro) del file e sostituisci il codice precedente con:
'========>>
Option Explicit
'-------->>
Private Sub Workbook_SheetChange(ByVal SH As Object, ByVal Target As Range)
Dim rBilancio_di_Apertura As Range
Dim rCaption As Range, rChiusura_del_Giorno As Range
Dim dBilancio As Double
With ThisWorkbook
If SH.Name = .Sheets(.Sheets.Count).Name Then Exit Sub
If Not IsNumeric(SH.Name) And SH.Name <> sNome_Primo_Foglio Then Exit Sub
End With
With SH
Set rBilancio_di_Apertura = .Next.Range(sBilancio_di_Apertura)
With .Columns(sColonna_Entrata)
Set rCaption = .Offset(0, -1).Find(What:=sStr, After:=.Offset(0, -1).Cells(1), LookIn:= _
xlFormulas2, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)
End With
Set rChiusura_del_Giorno = rCaption.Offset(0, 1).Resize(1, 2)
dBilancio = Application.Sum(rChiusura_del_Giorno.Value)
On Error GoTo XIT
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
With rBilancio_di_Apertura
.ClearContents
If rChiusura_del_Giorno.Cells(1) = "" Then
.Cells(2).Value = dBilancio
Else
.Cells(1).Value = dBilancio
End If
End With
End With
Call Update_Subsequent_Sheets(SH)
XIT:
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
'<<========
[erAck: edited to make that readable code, removed every second blank line and formatted as code block, see guide]