Hi guys, I have this macro that runs perfectly but I would like to use it in multiple files at the same time because right now just runs one at the same time, also I would like a little help because my "DataBase" is in another workbook is not in a sheet of the workbook I am working in, and right now to use the info in the "DataBase" I am adding a need sheet (in my actual workbook) with it, this is not the ideal, the ideal is write in the macro that the "Database" is in another workbook.
I hope you can help me, thank you in advance
Code
Sub replace2()
Application.ScreenUpdating = False
Const str As String = "PERSONE COINVOLTE DEL CAB"
Dim rCl As Range, ws As Worksheet, LastRow As Long, dbWS As Worksheet, Val As String, arr As Variant, arr2 As Variant, i As Long, x As Long
Set dbWS = Sheets("DataBase")
arr = dbWS.Range("A2", dbWS.Range("A" & Rows.Count).End(xlUp)).Resize(, 3).Value
arr2 = dbWS.Range("D2", dbWS.Range("D" & Rows.Count).End(xlUp)).Resize(, 2).Value
Worksheets("Giudizio sintetico").Visible = False
Worksheets("Riepilogo").Visible = False
With Sheets("Anagrafica audit")
Set rCl = .UsedRange.Find(str, LookIn:=xlValues, lookat:=xlWhole)
LastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Range("A" & rCl.Row + 2 & ":C" & LastRow).ClearContents
For i = 1 To UBound(arr2, 1)
.Range("B4").replace "?" & arr2(i, 1), arr2(i, 2)
Next i
.Range("b3:c3").UnMerge
.Range("b3").ClearContents
.Range("b5:c5").UnMerge
.Range("b5").ClearContents
For i = 1 To UBound(arr, 1)
Val = arr(i, 2) & " " & arr(i, 1)
.Cells.replace Val, arr(i, 3)
Sheets("report stampabile").Cells.replace Val, arr(i, 3)
Next i
End With
With Sheets("report stampabile")
For x = 14 To 420 Step 10
.Range("P" & x & ":S" & x).UnMerge
.Range("P" & x).ClearContents
Next x
End With
Sheets("DataBase").Delete
Application.ScreenUpdating = True
End Sub
Display More