看起来很简单,但我仍然无法弄清楚为什么每一个都被添加到 A 列,以及为什么不像我定义的 iRowB 那样添加到“AN”列
非常感谢您的帮助
Private Sub CommandButton1_Click()
Dim iRowA As Long
Dim iRowB As Long
Dim ws As Worksheet
Set ws = Worksheets("Results draft")
'find first empty row in database
iRowA = ws.Range("A:A").Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
iRowB = ws.Range("AN:AN").Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If Trim(Me.HomeTeam.Value) = "" Then
Me.HomeTeam.SetFocus
MsgBox "Please insert the result"
Exit Sub
End If
With ws
.Cells(iRowA, 1).Value = Me.HomeTeam.Value
.Cells(iRowB, 1).Value = Me.Goal1.Value
End With
End Sub