Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Paolo,
prova a vedere se così ci avviciniamo a quanto chiedi.
Sub Caso1()
Dim sh As Worksheet
Dim lRiga As Long
Dim rng1 As Range
Dim rng2 As Range
Set sh = ThisWorkbook.Worksheets("Foglio1")
With sh
If .FilterMode Then
lRiga = Split(.AutoFilter.Range.Address, "$")(4)
Set rng1 = .Range(.Cells(2, 5), .Cells(lRiga, 5))
For Each rng2 In rng1
If Not Intersect(rng1.SpecialCells(xlCellTypeVisible), rng2) Is Nothing Then
rng2.Offset(, 1).Value = rng2.Value
Else
rng2.Offset(, 1).ClearContents
End If
Next
Else
lRiga = .Range("E" & .Rows.Count).End(xlUp).Row
Set rng1 = .Range(.Cells(2, 5), .Cells(lRiga, 5))
rng1.Copy Destination:=rng1.Offset(, 1)
End If
End With
Set sh = Nothing
Set rng1 = Nothing
End Sub
Sub Caso2()
Dim sh As Worksheet
Dim lRiga As Long
Dim rng1 As Range
Dim rng2 As Range
Set sh = ThisWorkbook.Worksheets("Foglio1")
With sh
If .FilterMode Then
lRiga = Split(.AutoFilter.Range.Address, "$")(4)
Set rng1 = .Range(.Cells(2, 5), .Cells(lRiga, 5))
For Each rng2 In rng1
If Not Intersect(rng1.SpecialCells(xlCellTypeVisible), rng2) Is Nothing Then
rng2.Offset(, 1).Value = .Range("Q1")
Else
rng2.Offset(, 1).ClearContents
End If
Next
Else
lRiga = .Range("E" & .Rows.Count).End(xlUp).Row
Set rng1 = .Range(.Cells(2, 6), .Cells(lRiga, 6))
.Range("Q1").Copy Destination:=rng1
End If
End With
Set sh = Nothing
Set rng1 = Nothing
End Sub
David