
Private Sub CommandButton1_Click()
Dim NewLig As Long
With Worksheets("DATI")
NewLig = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
.Range("A" & NewLig).Value = Worksheets("SCHEDA").Range("B4").Value
.Range("B" & NewLig).Value = Worksheets("SCHEDA").Range("D4").Value
.Range("C" & NewLig).Value = Worksheets("SCHEDA").Range("B5").Value
.Range("D" & NewLig).Value = Worksheets("SCHEDA").Range("D5").Value
End With
Worksheets("SCHEDA").Range("B4").ClearContents
Worksheets("SCHEDA").Range("D4").ClearContents
Worksheets("SCHEDA").Range("B5").ClearContents
Worksheets("SCHEDA").Range("D5").ClearContents
End Sub |
'Una nota di stile.
'Invece di indicare una singola cella per volta, puoi raggruppare un intervallo
'e scrivere quindi solo una riga di codice invece di quattro:
Worksheets("SCHEDA").Range("B4:B5,D4:D5").ClearContents
'oppure, più sinteticamente:
[scheda!b4:b5,scheda!d4:d5].ClearContents |
Dim i as Integer
'si suppone che a partire da B2 *non* ci sono righe vuote in mezzo
'conta le righe piene quindi aggiunge uno
i = [b2].currentregion.rows.count
i = i + 1
'la cella i, 2 è la riga i, colonna B
sheets("dati").cells(i, 2) = [scheda!b4]
'prossima riga!
i = i + 1
sheets("dati").cells(i, 3) = [scheda!d4]
'attenzione, qui non cambio la riga e quindi dati!B3 viene sovrascritto :)
sheets("dati").cells(i, 3) = [scheda!b6] |
Private Sub CommandButton1_Click()
Dim ac As Range, i As Integer
For Each ac In [scheda!a1].CurrentRegion.Offset(1).Resize(, 1)
i = i + 1
Range(ac, ac.Offset(0, 1)).Copy
Sheets("dati").Cells(1, i).PasteSpecial Transpose:=True
Next
Application.CutCopyMode = False
End Sub |
Private Sub CommandButton1_Click()
Dim last_col As Integer
last_col = [dati!a2].CurrentRegion.Columns.Count
[scheda!a2:b2].Copy
Sheets("dati").Cells(1, last_col + 1).PasteSpecial Transpose:=True
Application.CutCopyMode = False
End Sub |
Private Sub CommandButton1_Click()
Dim last_col As Integer
last_col = [dati!a2].CurrentRegion.Columns.Count
'copia a2 da scheda a dati in riga 1, colonna la prima disponibile
[scheda!a2].Copy Sheets("dati").Cells(1, last_col + 1)
'copia b2 da scheda a dati in riga 2, colonna la prima disponibile
[scheda!b2].Copy Sheets("dati").Cells(2, last_col + 1)
Application.CutCopyMode = False
End Sub |
Private Sub CommandButton1_Click()
Dim NewCol As Integer
With Worksheets("DATI1")
NewCol = .Cells(4, .Columns.Count).End(xlToLeft).Column + 1
.Cells(3, NewCol).Value = Worksheets("SCHEDA").Range("B4").Value
.Cells(4, NewCol).Value = Worksheets("SCHEDA").Range("D4").Value
.Cells(5, NewCol).Value = Worksheets("SCHEDA").Range("B5").Value
.Cells(6, NewCol).Value = Worksheets("SCHEDA").Range("D5").Value
End With
Worksheets("SCHEDA").Range("B4").ClearContents
Worksheets("SCHEDA").Range("D4").ClearContents
Worksheets("SCHEDA").Range("B5").ClearContents
Worksheets("SCHEDA").Range("D5").ClearContents |
