Ciao Draleo,
In un modulo di codice standard di una cartella di lavoro diverso dai file di interesse, prova qualcosa del genere:
'========>>
Option Explicit
'-------->>
Public Sub Conclusione()
Dim destWB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim arrFile() As Variant
Dim sPath As String, sStr As String
Dim sFileName As String, sMsg As String
Dim nr As Long
Dim l As Long, iCtr As Long
Const sPercorso As String = "C:\Users\Draleo\Mia Cartella" '<<=== Modifica
Const SFoglio As String = "Database"
sStr = Application.PathSeparator
If Right(sPercorso, 1) = sStr Then
sPath = sPercorso
Else
sPath = sPercorso & sStr
End If
On Error GoTo ErrHandler
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
sFileName = Dir(sPath & "*.xlsm")
Do Until sFileName = ""
If sFileName <> ThisWorkbook.Name Then
Set destWB = Workbooks.Open(sPath & sFileName)
Set SH = destWB.Sheets(SFoglio)
With SH
nr = .Range("A65536").End(xlUp).Row
For l = nr To 4 Step -1
If .Cells(l, 9).Value = "" Then
.Cells(l, 9).Value = .Cells(l - 1, 9).Value
End If
Next l
Set Rng = .Range("B4:" & "B" & nr)
Rng.Replace What:="NZ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
.Range("X4").Value = "Pippo"
.Range("Y4") = "Pluto"
.Range("Z4").Value = "Paperino"
End With
iCtr = iCtr + 1
ReDim Preserve arrFile(1 To iCtr)
arrFile(iCtr) = destWB.Name
destWB.Close SaveChanges:=True
End If
sFileName = Dir()
Loop
If CBool(iCtr) Then
sMsg = Join(arrFile, vbNewLine)
Call MsgBox(Prompt:="File aggiornati:" & vbNewLine & sMsg, _
Buttons:=vbInformation, _
Title:="REPORT")
End If
XIT:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
On Error GoTo 0
Exit Sub
ErrHandler:
Call MsgBox(Prompt:="Errore " & Err.Number & " (" & Err.Description & ") nella procedura Conclusione", _
Buttons:=vbCritical, _
Title:="ERRORE")
Resume XIT
End Sub
'<<========
--
Regards,
Norman