Moderatori: Anthony47, Flash30005
Sub MacroTotali()
Dim CM As Long, CY As Long, mySplit, MMM As String
Cells(1, Columns.Count).End(xlToLeft).Select
'Cells(1, Columns.Count).End(xlToLeft).Offset(0, -1).Select
mySplit = Split(ActiveCell.Value & "-0-0", "-", , vbTextCompare)
CM = CLng("0" & mySplit(1))
CY = CLng("0" & mySplit(0))
MMM = UCase(Format(DateSerial(CY, CM, 1), "mmm"))
On Error Resume Next
ActiveCell.Offset(0, 1).Value = _
"Totale GEN-" & MMM & Chr(10) & Split(ActiveCell.Offset(0, -14).Value & "-0-0", "-", , vbTextCompare)(0)
ActiveCell.Offset(0, 2).Value = _
"Totale GEN-" & MMM & Chr(10) & mySplit(0)
ActiveCell.Offset(0, 3).Value = "Differenza"
On Error GoTo 0
ActiveCell.Offset(1, 1).FormulaR1C1 = _
"=SUM(OFFSET(RC[-1],0,1-" & CM & "-12,1," & CM & "))"
ActiveCell.Offset(1, 2).FormulaR1C1 = _
"=SUM(OFFSET(RC[-2],0,1-" & CM & ",1," & CM & "))"
ActiveCell.Offset(1, 3).FormulaR1C1 = _
"=RC[-1]-RC[-2]"
End Sub
="TOTALE
"&TESTO(C1;"#.##0")&"-- "&TESTO(F1;"#.##0")&"
("&TESTO(F1;"#.##0")&" )"
"Totale GEN-" & MMM & Chr(10) & Split(ActiveCell.Offset(0, -14).Value & "-0-0", "-", , vbTextCompare)(0)
Non sono in grado di eseguire questa sequenza perche’ ci sono all’interno di Sub CopiaCelleFiltrate domande a cui non ho idea di come rispondere, e sono necessarie per ottenere il foglio nella struttura voluta.dovresti lanciare [le macro] in questa sequenza.
1. Unisci_Files_InUno
2. Riunisci
3. Ordina_Righe_Corrispondenti
4. NumeriinNumero (per ovviare il solito problema dei numeri in formato testo)
5. A questo punto appare la InputBox per continuare dopo aver filtrato l’Agente
6. CopiaCelleFiltrate
Sub MacroTotali()
Dim CM As Long, CY As Long, mySplit, MMM As String
Cells(1, Columns.count).End(xlToLeft).Select
'Cells(1, Columns.Count).End(xlToLeft).Offset(0, -1).Select
mySplit = Split(ActiveCell.Value & "-0-0", "-", , vbTextCompare)
CM = CLng("0" & mySplit(1))
CY = CLng("0" & mySplit(0))
MMM = UCase(Format(DateSerial(CY, CM, 1), "mmm"))
On Error Resume Next
'DA QUI:
ActiveCell.Offset(0, 1).Value = _
"Totale" & Chr(10) & "01 GEN-" & UCase(Format(Date, "dd-mmm")) & Chr(10) & Split(Range("C1").Value & "-0-0", "-", , vbTextCompare)(0)
ActiveCell.Offset(0, 2).Value = _
"Totale" & Chr(10) & "01 GEN-" & UCase(Format(Date, "dd-mmm")) & Chr(10) & mySplit(0)
ActiveCell.Offset(0, 3).Value = "Differenza"
ActiveCell.Offset(1, 1).Formula = "=SUM(OFFSET(C1,1,0,1," & CM & "))"
ActiveCell.Offset(1, 2).FormulaR1C1 = "=SUM(OFFSET(RC,0,-1+" & -CM & ",1," & CM & "))"
ActiveCell.Offset(1, 3).FormulaR1C1 = "=RC[-1]-RC[-2]"
End Sub
Una domanda: il 7 Agosto, dopo aver scaricato i due file del 24 e del 25 per lo stesso periodo 01.01 al 07.08,2024 e uguale per il 2025, le intestazioni saranno 01 GEN-07-AGO ?
Sub MacroTotali()
Dim CM As Long, CY As Long, mySplit, MMM As String
Cells(1, Columns.count).End(xlToLeft).Offset(0, -1).Select
'Cells(1, Columns.Count).End(xlToLeft).Offset(0, -1).Select
mySplit = Split(ActiveCell.Value & "-0-0", "-", , vbTextCompare)
CM = CLng("0" & mySplit(1))
CY = CLng("0" & mySplit(0))
MMM = UCase(Format(DateSerial(CY, CM, 1), "mmm"))
On Error Resume Next
ActiveCell.Offset(0, 3).Value = _
"Totale" & Chr(10) & "01 GEN-" & UCase(Format(Date, "dd-mmm")) & Chr(10) & Split(Range("C1").Value & "-0-0", "-", , vbTextCompare)(0)
ActiveCell.Offset(0, 4).Value = _
"Totale" & Chr(10) & "01 GEN-" & UCase(Format(Date, "dd-mmm")) & Chr(10) & mySplit(0)
ActiveCell.Offset(0, 5).Value = "Differenza"
ActiveCell.Offset(1, 3).Formula = "=SUM(OFFSET(C1,1,0,1," & CM & "))"
ActiveCell.Offset(1, 4).FormulaR1C1 = "=SUM(OFFSET(RC,0,-3+" & -CM & ",1," & CM & "))"
ActiveCell.Offset(1, 5).FormulaR1C1 = "=RC[-1]-RC[-2]"
End Sub
Quindi, nelle ipotesi:
-colonna Totale presente
-colonne per la comparazione separate da una colonna vuota
-foglio privo di righe nascoste
etc etc
Torna a Applicazioni Office Windows
Supporto per sviluppo macro VBA Ordinare per data Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 3 |
Excel: problema con date se devo unirle a testi Autore: valle1975 |
Forum: Applicazioni Office Windows Risposte: 5 |
Macro per aprire file salvato su sharepoint Onedrive Autore: marcopont |
Forum: Applicazioni Office Windows Risposte: 2 |
Visitano il forum: Nessuno e 17 ospiti