【发布时间】:2014-03-26 06:17:17
【问题描述】:
我编写了一个 VBA 宏,它尝试从用户表单中的文本框中获取输入值,并将它们复制到特定工作表上的单元格中。我还编写了一个 countA 函数,该函数允许我每次点击输入按钮时写入一个新行。由于我无法理解的原因,无论我参考什么工作表,它都只会写入活动工作表。请帮忙!
Private Sub inputlight_Click()
Dim emptyrow As Long
'Find the first empty row after row 47 on sheet "T5 Input Sheet"
emptyrow = 47 + WorksheetFunction.CountA(Sheets("T5 Input Sheet").Range("b48:b219")) + 1
'transfer data
Cells(emptyrow, 2).Value = esize.Value
Cells(emptyrow, 3).Value = etype.Value
Cells(emptyrow, 4).Value = ewatt.Value
Cells(emptyrow, 5).Value = elamps.Value
Cells(emptyrow, 6).Value = eusage.Value
Cells(emptyrow, 7).Value = efixtures.Value
End Sub
我尝试将其更改为 CountA(Worksheets("T5 Input Sheet"), (Sheets(2)), (Sheets("Sheet2") 等,但它们都不会打印到活动单元格之外的任何内容。什么我做错了吗?
【问题讨论】:
-
您需要资格
Cells