这是我子程序的第一部分
Sub AddReceiptToBlankCell()
' On the members named sheet, find the row for the entered year + term + course
Dim EnrollSheet As Worksheet
Dim enteredyear As String
Dim term As String
Dim course As String
Set EnrollSheet = Worksheets("Enroll Course")
enteredyear = Worksheets("Enroll Course").Range("C3").Value
term = Worksheets("Enroll Course").Range("C4").Value
course = Worksheets("Enroll Course").Range("C6").Value
' find the row for the selected Year, Term and Course.
'With Worksheets("Bloggs, Joe")
With Worksheets("Enroll Course").Range("C5").Value
LastRow1 = .Cells(Rows.Count, "A").End(xlUp).Row
在单元格C5的“注册”课程表中输入人员姓名。 当我运行它时,我得到一个运行时错误424' Object Required'在行
With Worksheets("Enroll Course").Range("C5").Value
但如果我使用此声明(使用实际名称),我不会收到任何错误
With Worksheets("Bloggs, Joe")
我尝试使用此功能,但收到相同的错误消息
Dim MembersSheet As Worksheet
Set MembersSheet = Worksheets("Enroll Course").Range("C5").Value
With MembersSheet
我做错了什么?
答案 0 :(得分:0)
更改行:
With Worksheets("Enroll Course").Range("C5").Value
使用:
With Worksheets(Worksheets("Enroll Course").Range("C5").Value)
由于Worksheets("Enroll Course").Range("C5").Value
的值是String
(或数字),然后您想在Worksheet
对象引用中使用该字符串,例如With Worksheet("SheetName")