
With my_range_2
For Each Cella_1 In my_range_3
Set range_a = .Find(what:=Cella_1, LookIn:=xlValues)
If Not range_a Is Nothing Then |
Sub Estrazione_generale()
Dim sws As String
Dim ws As Worksheet
Dim sWsName As String
Dim wbk_1 As Workbook
Dim fso As Object
Dim my_range_1 As Range
Dim my_range_2 As Range
Dim my_range_3 As Range
Dim range_a As Range
Dim range_a_row As Integer
Dim range_a_column As Integer
Dim range_b_row As Integer
Dim range_b_column As Integer
Dim Cella As Range
Dim Cella_1 As Range
Dim Cella_2 As Double
Dim Cella_3 As String
Dim wSheet As Worksheet
Set wbk_1 = ThisWorkbook
Set fso = CreateObject("Scripting.FileSystemObject")
Set my_range_1 = wbk_1.Sheets("Generale").Range("B4:B20000").SpecialCells(xlCellTypeConstants)
Set my_range_3 = wbk_1.Sheets("Generale").Range("d2:BBB2").SpecialCells(xlCellTypeConstants)
For Each ws In wbk_1.Worksheets
sws = sws & "#" & ws.Name
Next
sws = sws & "#"
For Each Cella In my_range_1
sWsName = Trim(Cella.Value)
If InStr(1, sws, "#" & sWsName & "#", vbTextCompare) > 0 Then
Set my_range_2 = wbk_1.Sheets(sWsName).Range("d16:d20000")
'Set my_range_2 = wbk_1.Sheets(Trim(Cella)).Range("d16:d2000").SpecialCells(xlCellTypeConstants)
With my_range_2
For Each Cella_1 In my_range_3
Set range_a = .Find(what:=Cella_1, LookIn:=xlValues, LookAt:=xlWhole)
If Not range_a Is Nothing Then
range_a_row = range_a.Row
range_a_column = range_a.Column
range_b_row = Cella_1.Row
range_b_column = Cella_1.Column
Cella_2 = wbk_1.Sheets(Trim(Cella)).Range("h" & range_a_row)
wbk_1.Sheets("Generale").Cells(Cella.Row, range_b_column) = Cella_2
End If
Next
End With
End If
'End If
Next
End Sub
|
Sub Estrazione_generale()
Dim sws As String
Dim ws As Worksheet
Dim sWsName As String
Dim wbk_1 As Workbook
Dim fso As Object
Dim my_range_1 As Range
Dim my_range_2 As Range
Dim my_range_3 As Range
Dim range_a As Range
Dim range_a_row As Integer
Dim range_a_column As Integer
Dim first As String
Dim range_b_row As Integer
Dim range_b_column As Integer
Dim Cella As Range
Dim Cella_1 As Range
Dim Cella_2 As Double
Dim Cella_3 As Double
Dim Cella_4 As Double
Dim wSheet As Worksheet
Set wbk_1 = ThisWorkbook
Cella_4 = 0
Set fso = CreateObject("Scripting.FileSystemObject")
Set my_range_1 = wbk_1.Sheets("Generale").Range("B4:B20000").SpecialCells(xlCellTypeConstants)
Set my_range_3 = wbk_1.Sheets("Generale").Range("d2:BBB2").SpecialCells(xlCellTypeConstants)
For Each ws In wbk_1.Worksheets
sws = sws & "#" & ws.Name
Next
sws = sws & "#"
For Each Cella In my_range_1
sWsName = Trim(Cella.Value)
If InStr(1, sws, "#" & sWsName & "#", vbTextCompare) > 0 Then
Set my_range_2 = wbk_1.Sheets(sWsName).Range("d16:d1000")
With my_range_2
For Each Cella_1 In my_range_3
Set range_a = .Find(what:=Cella_1, LookIn:=xlValues, LookAt:=xlWhole)
Cella_2 = 0
Cella_3 = 0
Cella_4 = 0
If Not range_a Is Nothing Then
range_a_row = range_a.Row
range_a_column = range_a.Column
range_b_row = Cella_1.Row
range_b_column = Cella_1.Column
Cella_2 = wbk_1.Sheets(Trim(Cella)).Range("h" & range_a_row)
first = range_a.Address
'wbk_1.Sheets("Generale").Cells(Cella.Row, range_b_column) = Cella_2
Do
Set range_a = .FindNext(After:=range_a)
If Not range_a Is Nothing Then
range_a_row = range_a.Row
range_a_column = range_a.Column
range_b_row = Cella_1.Row
range_b_column = Cella_1.Column
Cella_3 = wbk_1.Sheets(Trim(Cella)).Range("h" & range_a_row)
Cella_4 = Cella_3 + Cella_4
End If
Loop While Not range_a Is Nothing And range_a.Address <> first
wbk_1.Sheets("Generale").Cells(Cella.Row, Cella_1.Column) = Cella_2 + Cella_4
End If
Next
End With
End If
'End If
Next
End Sub
|
