
Sub Crea_Pulsante()
ActiveSheet.Unprotect
'Crea un pulsante: 1° coordinata X, 2° coordinata Y DALL'ALTO, 3° larghezza, 4° altezza pulsante
ActiveSheet.Buttons.Add(610, 950, 170, 70).Select
'Rinomina il pulsante
Set shp = ActiveSheet.Shapes(Selection.Name)
With shp.OLEFormat.Object
.Name = "Button10"
End With
'Assegna la macro al pulsante
Selection.OnAction = "Riporto"
'Inserisce e formatta la didascalia nel pulsante
Selection.Characters.Text = "Riporto"
With Selection.Characters(Start:=1, Length:=11).Font
.Name = "Calibri"
.FontStyle = "Grassetto"
.Size = 15
.ColorIndex = 1
End With
Range("G81").Select
ActiveSheet.Protect
End Sub
|
Sub Crea_Pulsante()
Dim i As Long
For i = 1 To 3
Worksheets(i).Unprotect
Worksheets(i).Select
'Crea un pulsante: 1° coordinata X, 2° coordinata Y DALL'ALTO, 3° larghezza, 4° altezza pulsante
ActiveSheet.Buttons.Add(610, 950, 170, 70).Select
'Rinomina il pulsante
Set shp = ActiveSheet.Shapes(Selection.Name)
With shp.OLEFormat.Object
.Name = "Button10"
End With
'Assegna la macro al pulsante
Selection.OnAction = "Riporto"
'Inserisce e formatta la didascalia nel pulsante
Selection.Characters.Text = "Riporto"
With Selection.Characters(Start:=1, Length:=11).Font
.Name = "Calibri"
.FontStyle = "Grassetto"
.Size = 15
.ColorIndex = 1
End With
Range("G81").Select
Worksheets(i).Protect
Next i
End Sub
|
Sub Riporto()
Dim i As Long
For i = 1 To 3
Worksheets(i).Unprotect
Worksheets(i).Select
'
' Riporto Macro
' Macro registrata il 28/10/2014 da Utente
'
' Scelta rapida da tastiera: CTRL+a
'
ActiveWindow.SmallScroll Down:=66
Range("G81:I81").Select
Selection.Copy
Range("G79").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G81").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=6
Range("G85:I85").Select
Selection.Copy
Range("G83").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G85").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("G89:I89").Select
Selection.Copy
Range("G87").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G89").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=3
Range("G93:I93").Select
Selection.Copy
Range("G91:I91").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G93").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=6
Range("H101").Select
Selection.Copy
Range("H97").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H101").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("Foglio2").Select
Range("G18").Select
ActiveWindow.SmallScroll Down:=3
Sheets("Foglio3").Select
Range("L43").Select
Selection.Copy
Sheets("Foglio2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=6
Sheets("Foglio3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("Foglio3").Select
ActiveWindow.SmallScroll Down:=-24
Range("H22").Select
Selection.Copy
Range("H5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H22").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("Foglio1").Select
ActiveWindow.SmallScroll Down:=-81
Range("A7:J39").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=36
Range("A41:J52").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=9
Range("A54:J62").Select
Selection.ClearContents
Selection.ClearContents
Range("A64:J67").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=18
Sheets("Foglio2").Select
ActiveWindow.SmallScroll Down:=9
Range("D20:F46").Select
Selection.ClearContents
Range("G20:G46").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=15
Range("A53:G64").Select
Selection.ClearContents
Sheets("Foglio3").Select
Range("D7:H20").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=21
Range("B33:H45").Select
Selection.ClearContents
Range("G30:H32").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=18
Sheets("Foglio1").Select
ActiveWindow.SmallScroll Down:=-69
'Cancella il pulsante
ActiveSheet.Shapes.Range(Array("Button10")).Delete
'Imposta un timer che lo ri-genera dopo un tempo determinato
Application.OnTime Now + TimeValue("00:00:05"), "Crea_Pulsante"
Worksheets(i).Protect
Next i
End Sub
Sub Crea_Pulsante()
Dim i As Long
For i = 1 To 3
Worksheets(i).Unprotect
Worksheets(i).Select
'Crea un pulsante: 1° coordinata X, 2° coordinata Y DALL'ALTO, 3° larghezza, 4° altezza pulsante
ActiveSheet.Buttons.Add(610, 950, 170, 70).Select
'Rinomina il pulsante
Set shp = ActiveSheet.Shapes(Selection.Name)
With shp.OLEFormat.Object
.Name = "Button10"
End With
'Assegna la macro al pulsante
Selection.OnAction = "Riporto"
'Inserisce e formatta la didascalia nel pulsante
Selection.Characters.Text = "Riporto"
With Selection.Characters(Start:=1, Length:=11).Font
.Name = "Calibri"
.FontStyle = "Grassetto"
.Size = 15
.ColorIndex = 1
End With
Range("G81").Select
Worksheets(i).Protect
Next i
End Sub
|
ActiveWindow.SmallScroll Down:=66 'istruzione inutile, poichè il registratore ha registrato lo spostamento verso il basso
Range("G81:I81").Select
Selection.Copy
Range("G79").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks :=False, Transpose:=False
'Le istruzioni sopra possono essere rese più sintetiche:
Range("G81:I81").Copy '<=per copiare o incollare una cella non serve selezionarla, lo stesso per tutte le operazioni su un range
Range("G81:I81").PasteSpecial xlPasteValues |
Sub Crea_Pulsante(Sh As Worksheet)
Dim Bt As Object
With Sh
.Unprotect
Set Bt = .Buttons.Add(610, 950, 170, 70)
Bt.OnAction = "Riporto"
With Bt
.Name = "Button10"
.Caption = "Riporto"
With .Font
.Name = "Calibri"
.Bold = True
.Size = 15
.ColorIndex = 1
End With
End With
Set Bt = Nothing
.Protect
End With
End Sub
Sub PulsantiSuTreFogli()
Dim N As Long
For N = 1 To 3
Crea_Pulsante ThisWorkbook.Sheets(N)
Next N
End Sub
|
Sheets("Foglio3").Select
Range("H22").Copy 'RIPORTO SPESE GENERALE
Range("H5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H22").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("D7:H20").ClearContents 'vari contenuti da cancellare, ma oltre questi range mi cancella anche altre celle che non dovrebbe
Range("G30:H32").ClearContents
Range("B33:H45").ClearContents
Range("H22").Select |
Sheets("Foglio3").Select 'RIPORTO ASSEGNI E CONTANTI
Range("L43").Copy
Sheets("Foglio2").Select
Range("G18").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("L43").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("Foglio2").Select
Range("D20:G4").ClearContents
Range("A53:G60").ClearContents
Range("L43").Select
|
