我的userform可以正常填写Excel电子表格中的字段,但它拒绝移动到下一行。我不能通过要求找到空行来做到这一点,因为列A和C是预先填充的。有没有办法让userform在完成并提交并填写字段后跳转到下一行,也许可以使用B列来了解该行是否可以使用?因为无论如何,A和C列都被填充。 此外,一旦用户完成,保存文档,稍后再回来,用户是否会选择上次停止的任何行?我知道我已经发布了这个,但没有解决方案有效,我想我会添加更多细节。对不起,如果其中一些似乎是新手,我是VBA的新手。谢谢!
Private Sub butOK_Click()
Dim RowCount As Long
Dim ctl As Control
RowCount = Worksheets("EXPECTED RETURNS").Range("A6865").CurrentRegion.Rows.Count
With Worksheets("EXPECTED RETURNS").Range("A6865")
.Offset(LastRow, 1).Value = Me.txtDate.Value
.Offset(LastRow, 3).Value = Me.txtDevice.Value
.Offset(LastRow, 4).Value = Me.txtID.Value
.Offset(LastRow, 5).Value = Me.txtSN.Value
.Offset(LastRow, 6).Value = Me.txtTrans.Value
.Offset(LastRow, 7).Value = Me.txtIDTrans.Value
.Offset(LastRow, 8).Value = Me.txtMS.Value
.Offset(LastRow, 9).Value = Me.txtCountry.Value
.Offset(LastRow, 10).Value = Me.txtCamp.Value
.Offset(LastRow, 11).Value = Me.txtOrig.Value
.Offset(LastRow, 12).Value = Me.txtProgram.Value
.Offset(LastRow, 13).Value = Me.txtPOC.Value
.Offset(LastRow, 14).Value = Me.txtPOCEmail.Value
.Offset(LastRow, 15).Value = Me.txtDSN.Value
.Offset(LastRow, 16).Value = Me.txtIR.Value
.Offset(LastRow, 17).Value = Me.txtEI.Value
End With
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
ctl.Value = ""
ElseIf TypeName(ctl) = "CheckBox" Then
ctl.Value = False
End If
Next ctl
End Sub