
'un modo, e neanche il più elegante: last_row = sheets(1).cells(sheets(1).rows.count,1).end(xlup).row |
Private Sub CommandButton1_Click()
Dim lRiga As Long
With Worksheets("Foglio2")
lRiga = .Range("b" & Rows.Count).End(xlUp).Row
.Cells(lRiga + 1, 2).Select
Cells(lRiga + 1, 2).Value = DTPicker1
End With
End Sub |
Cells(lRiga + 1, 2).Value = DTPicker1
.Cells(lRiga + 1, 2).Value = DTPicker1
Private Sub CommandButton1_Click()
Dim lRiga As Long
With Worksheets("Foglio2")
lRiga = .Range("b" & Rows.Count).End(xlUp).Row
.Cells(lRiga + 1, 2).Value = DTPicker1
.Cells(lRiga + 1, 3).Value = FormatDateTime(Now(), vbShortTime)
End With
End Sub |
Private Sub CommandButton1_Click()
Dim lRiga As Long
With Worksheets("Foglio2")
lRiga = .Range("b" & Rows.Count).End(xlUp).Row
.Cells(lRiga + 1, 2).Value = DTPicker1
.Cells(lRiga + 1, 3).Value = TextBox1
End With
End Sub
Private Sub CommandButton2_Click()
Dim lRiga As Long
With Worksheets("Foglio2")
lRiga = .Range("e" & Rows.Count).End(xlUp).Row
.Cells(lRiga + 1, 5).Value = DTPicker1
.Cells(lRiga + 1, 6).Value = TextBox1
End With
End Sub |
Option Explicit
Private Sub CommandButton1_Click()
Call inserisci_data_ora(1)
End Sub
Private Sub CommandButton2_Click()
Call inserisci_data_ora(2)
End Sub
Private Sub inserisci_data_ora(i as integer)
Dim lRiga As Long
With Worksheets("Foglio2")
lRiga = .Range("b" & Rows.Count).End(xlUp).Row
.Cells(lRiga + 1, IIf(i = 1, 2, 5)).Value = DTPicker1
.Cells(lRiga + 1, IIf(i = 2, 3, 6)).Value = TextBox1
End With
End Sub |
'codice di userform1
'non Private Sub Form_Load() ma:
Private Sub userform_initialize()
Me.TextBox1.Text = Format(Now, "DD/MM/YYYY")
End Sub |
