【发布时间】:2017-04-23 11:46:38
【问题描述】:
我的问题在于“A”列。在此列中,今天的日期应粘贴在第一个空白行中。但是我把它粘贴了两次。第一次显示 UserForm1,第二次单击 CommandButton1。其他一切正常(来自 UserForm1 的数据粘贴到最后一行 + 1。问题仅与列“A”有关。 请在下面找到代码:
Private Sub CommandButton1_Click()
Call UserForm_Initialize
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim LastRow As Long, ws As Worksheet
'UserForm1.Label9.Caption = ws.Range("A1").Value
Set ws = Sheets("Log")
With ComboBox1
.AddItem "Quality"
.AddItem "Time"
.AddItem "Money"
End With
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1 'ostatni wiersz
'entry date
ws.Range("A1").Copy
Sheets("Log").Range("A" & LastRow).PasteSpecial xlPasteValues
'pasting data from form
'ws.Range("A" & LastRow).Value = Label9.Caption
ws.Range("B" & LastRow).Value = TextBox8.Text
ws.Range("C" & LastRow).Value = TextBox1.Text
ws.Range("D" & LastRow).Value = TextBox2.Text
ws.Range("E" & LastRow).Value = TextBox3.Text
ws.Range("F" & LastRow).Value = TextBox4.Text
ws.Range("G" & LastRow).Value = TextBox5.Text
ws.Range("H" & LastRow).Value = ComboBox1.Text
ws.Range("I" & LastRow).Value = TextBox6.Text
ws.Range("J" & LastRow).Value = TextBox7.Text
End Sub
请帮忙。
【问题讨论】: