我正在尝试构建一个基于 excel 的输入表单,我在网上找到了一些东西,我正在尝试理解这些代码:
Dim Hsheet,Isheet As Worksheet
Dim NextRow, oCol As Long
Dim MyRng, MyCell As Range
Dim MyCopy, ClearCells As String
Set Hsheet = Worksheet("InputForm")
Set ISheet = Worksheet("Database")
这是我不明白的部分,有人可以给我解释一下吗?
With Hsheet
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With
With Isheet
Set myRng = .Range(MyCopy)
If Application.CountA(myRng) <> myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With
还有这部分,有人可以向我解释一下吗?
With Hsheet
.Cells(nextRow, "a").Value = Application.UserName
oCol = 1
For Each myCell In MyRng.Cells
Hsheet.Cells(NextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With
提前致谢 :)
With Isheet
On Error Resume Next
With .Range(ClearCells).Cells.SpecialCells(xlCellTypeConstants)
.ClearContents
Application.Goto .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With