我試圖建立一個基於Excel輸入表格,我在網上找到的東西,我想明白這些代碼:Excel的VBA代碼的理解
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
什麼是你的問題的柱A存儲在表
Isheet
從範圍MyRng值是多少? –那部分代碼找到了你可以添加新數據的下一行 –
@Austin Meriles:我剛剛編輯了我的帖子 – Nucleus