I'm trying to enter data into two sheets at once. Everything works fine except in the sheet 2, it doesn't put data on the last used row, which should be A2. Instead, it keeps adding data from A13 and below. I deleted everything in the sheet and when I enter the data, it goes to A14, repeat the same thing, it goes to A15 and so on.
what am I doing wrong here? The sheet 1 works as it's supposed to.
couldn't find an answer to this on the site.
what am I doing wrong here? The sheet 1 works as it's supposed to.
couldn't find an answer to this on the site.
VBA Code:
Private Sub CommandButton2_Click()
Dim x As Long
Dim y, z As Worksheet
Set y = Sheet1
Set z = Sheet2
x = z.Range("A" & Rows.Count).End(xlUp).Row + 1
x = y.Range("A" & Rows.Count).End(xlUp).Row + 1
With z
.Cells(x, 1).Value = [Text(Now(), "MM-DD-YYYY")] 'DATE
.Cells(x, 2).Value = ComboBox3.Text 'DETAILS
.Cells(x, 3).Value = ComboBox5.Text 'DURATION
.Cells(x, 4).Value = TextBox2.Text 'WEIGHT
'.Cells(x, 5).Value = ComboBox2.Text 'TYPE
'.Cells(x, 6).Value = ComboBox1.Text 'DEPT
'.Cells(x, 8) = [Text(Now(), "DD-MM-YYYY HH:MM")]
End With
With y
.Cells(x, 1).Value = [Text(Now(), "MM-DD-YYYY")] 'DATE
.Cells(x, 2).Value = ComboBox3.Text 'DETAILS
.Cells(x, 3).Value = ComboBox5.Text 'DURATION
.Cells(x, 4).Value = TextBox2.Text 'WEIGHT
'.Cells(x, 5).Value = ComboBox2.Text 'TYPE
'.Cells(x, 6).Value = ComboBox1.Text 'DEPT
'.Cells(x, 8) = [Text(Now(), "DD-MM-YYYY HH:MM")]
End With
Unload Me
D001.Show
End Sub