공개 함수의 VBA 런타임 오류 -2147319767(80028029) (VBA Run-time error -2147319767 (80028029) in Public Function)


문제 설명

공개 함수의 VBA 런타임 오류 ‑2147319767(80028029) (VBA Run‑time error ‑2147319767 (80028029) in Public Function)

이 오류는 오늘 다음 코드에서 나타납니다.

Public lngLast_CS_Sheet As Long
Public lngCS1_Index As Long
Public lngCSLast_Index As Long
6
Public Function num_CSx_Sheets()        'Function to find total number of CS Sheets
    Dim w As Long, cs As Long
    For w = 1 To Sheets.Count
        cs = cs ‑ CBool(UCase(Left(Sheets(w).Name, 2)) = "CS")
    Next w
    num_CSx_Sheets = cs
End Function

이 함수는 몇 년 동안 제대로 작동했지만 w = 17 & cs = 4

CS 시트의 범위에서 사용자의 잘못된 이름 지정을 확인했지만 문제를 찾을 수 없습니다.

함수는 다음 코드에 의해 호출됩니다.

Sub BoMLookUpMaterials_2019_Rev_B()
'
' BoMSearch CS Sheets Macro ‑ Modified 11/01/19 ‑ PRS
'
Dim FirstSheet As Integer
Dim LastSheet As Integer
Dim LastRow As Integer
Dim FirstRow As Integer
Dim ItemQTY As Single
Dim sSheetName As String
Dim sItemName As String

With ActiveSheet
    LastRow = Cells(.Rows.Count, "Q").End(xlUp).Row                      'Find last row of BoM (Qty) Col Q
End With
'
sSheetName = ActiveSheet.Name                                            'Get sheet name of active Database sheet
'
lngLast_CS_Sheet = num_CSx_Sheets()                                     'Find total number of CS sheets
lngCS1_Index = Sheets("CS1").Index                                      'CS1 Sheet Index No.
lngCSLast_Index = Sheets("CS" & lngLast_CS_Sheet).Index                 'Last CS Sheet Index No.

Select Case sSheetName                                                  'Determines which BoM sheet initiated Update BOM procedure

나는 경험 많은 VBA 프로그래머가 아니며 이것이 왜 지금 발생하는지 이해할 수 없습니다. 누군가 나에게 올바른 방향을 알려줄 수 있습니까?


참조 솔루션

방법 1:

I don't think this is a code issue as further testing by making lngLast_CS_Sheet equal the number of CS sheets in the workbook, the code runs without error. This error has only occurred in this workbook and not others with exactly the same code modules. Therefore I conclude this to be a user induced error somewhere within the workbook which I will tray & track down

(by Paul_SPaul_S)

참조 문서

  1. VBA Run‑time error ‑2147319767 (80028029) in Public Function (CC BY‑SA 2.5/3.0/4.0)

#vba #excel






관련 질문

열에 문자열이 포함된 경우 열 번호 나열 (List column numbers if columns contain string)

SpinButton SpinUp 또는 SpinDown 새로 고침 (Refreshing SpinButton SpinUp or SpinDown)

변수를 사용하여 Excel VBA에서 3차원 배열 요소에 액세스 (Use variables to access 3 dimensional array elements in Excel VBA)

TODAY() 함수와 월 1일을 기준으로 범위 이동 (Moving a range based on TODAY() function and first of the month)

ALV 레이아웃의 표시된 모든 열을 제거하는 방법 (How to remove all displayed columns of ALV layout)

셀에 입력한 msoShapeOval은 MsoShapeType으로 선언된 변수의 값이 될 수 없습니다. (msoShapeOval entered in cell not allowed to be value for variable declared as MsoShapeType)

Excel VBA의 세로 열에 여러 json을 생성하는 방법은 무엇입니까? (How to generate multiple json in vertical column in Excel VBA?)

공개 함수의 VBA 런타임 오류 -2147319767(80028029) (VBA Run-time error -2147319767 (80028029) in Public Function)

알 수 없는 수의 문자를 패턴 일치시키는 방법 (How to Pattern Match an Unknown Number of Characters)

Excel VBA 파일이 열려 있는지 확인 기능 (Excel VBA Check if File is open function)

ActiveCell..Offset(-1,0)=을 사용하는 If/And/Then/Else 문의 VBA 문제= (VBA Issue with If/And/Then/Else statement using ActiveCell..Offset(-1,0)=)

VBA 런타임 오류 '1004': 응용 프로그램 정의 또는 개체 정의 오류" 설정 셀 내용 (VBA Runtime Error '1004': Application-defined or Object-defined error" setting cell contents)







코멘트