Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Nicola,
I dati li ho sul foglio chiamato Riepilogo ed attualmente in colonna I con intestazione :Irpef.
Ti ho voluto fornire lo scenario reale.
Il mio codice precedente presumeva (erroneamente) che la colonna fosse denominata IRPEF anziché essere l'intestazione della colonna! Prova la seguente versione, adattando i nomi dei fogli come richiesto:
'========>>
Option Explicit
'-------->>
Public Sub Controlla_Valori_Maggiori_di_0() ' questa è la routine che somma la colonna IRPEF e la aggiunge alla fine per xxxxxxxxxxxxxxxxxxxx
Dim srcSH As Worksheet, destSH As Worksheet
Dim srcRng As Range, destRng As Range
Dim rCell As Range
Dim Si27 As Long, No27 As Long
Dim Res As Variant
With ThisWorkbook
Set srcSH = .Worksheets("Riepilogo")
Set destSH = .Worksheets("Foglio1")
End With
With srcSH
Set srcRng = .Range("I2:I" & .Cells(.Rows.Count, "I").End(xlUp).Row)
End With
For Each rCell In srcRng.Cells
If rCell.Value > 0 Then
Si27 = Si27 + 1
Else
No27 = No27 + 1
End If
Next rCell
If Si27 > 0 Then
With destSH
Res = Application.Match("IRPEF", .Rows(1), 0)
If Not IsError(Res) Then
Set destRng = .Cells(.Rows.Count, Res).End(xlUp)(2)
Else
Call MsgBox(Prompt:="L'intestazione IRPEF non è stata trovata nella riga 1 del foglio di destinazione!", Buttons:=vbInformation, Title:="REPORT")
Exit Sub
End If
End With
With destRng
.Value = Application.Sum(srcRng)
.Offset(, 1) = "xxxxxxxxxxxxxxxxxxxxxxx"
.Offset(, 2) = "xxxxxxxxxxxxxxxxxxxxxxxx"
.Offset(, 3) = "xxxxxxxxxxxxxxxxxxxxxxxxx"
.Offset(, 5) = "xxxxxxxxxxxx"
.Offset(, -2) = Date
.Offset(, -1) = "xxxxxxxxxxxxxxx"
.Offset(, 8) = "IRPEF"
End With
End If
MsgBox "Ho finito!! Spedisci il Flusso!!", vbInformation
End Sub
'<<========
===
Regards,
Norman