저는 주로 C++/C# 프로그래머이고 VBA에 익숙하지 않으므로이 코드의 문제점이 무엇인지는 확실하지 않습니다. 다음과 같은 오류가 발생합니다 :개체 변수가 설정되지 않았습니다?
"Run-time error '91': Object variable or With block variable not set."
FOR 루프의 줄에 오류가 발생했습니다. 진술의 오른쪽 부분이 오류를 던지고있는 것 같습니다. 그 라인의 문제는 정확히 무엇이며 어떻게 고칠 것인가?
Option Explicit
Private gEmployees() As Employee
Const gLastNameStartingCell = "A4"
Const gNamesCountCell = "A1"
Const gNamesTab = "NamesTab"
Function BuildEmployeeNameArray()
' Declare all variables
Dim iNameCount As Integer
Dim wksActive As Object
' Counter
Dim i As Integer
' Select the sheet with all the names
Set wksActive = Sheets(gNamesTab)
' Get the number of names on the sheet
iNameCount = wksActive.Range(gNamesCountCell)
' Resize the Array as appropriate
ReDim gEmployees(0 To iNameCount - 1)
' Fill out the employee list
For i = 0 To iNameCount - 1
gEmployees(i).mLastName = wksActive.Range(gLastNameStartingCell).Offset(i, 0).Value
Next i
End Function
직원은 클래스 모듈입니다 :
다음은 코드입니다. 이 파일의 관련 정보는 다음과 같습니다.
Option Explicit
Public mLastName As String
Private Sub Class_Initialize()
' Initialize variables
mLastName = ""
End Sub
아, 그 "설정"은 제가 놓친 것입니다 ... 나는 똑같은 자리에서 습관적으로 사용하려고 시도했지만 오류도 던졌습니다. 이것은 문자 그대로 가상 기본의 어떤 형태로 던져지고 하루 중 하나입니다, 그래서 나는 어둠 속에서 조금 주위를 느끼고 있어요. – Ishnatal