오류 라인은 다음과 같습니다런타임 오류 1004 엑셀 VBA를
If Sheets(1).Cells(6, i).Value = "AC POWER (LVL1)" Then
코드 :
Function getParam(Parameter As String)
'For Testing Purposes
Dim paramList, columnVals
Dim lastRow, lastCol, currentRow, currentCol, lvl1, foundCol As Long
Dim role8Loc, acpowerLoc, paramLoc, role8for2 As Long
lastRow = Sheets(1).Range("A65536").End(xlUp).Row
lastCol = Sheets(1).Range("A6").CurrentRegion.columns.Count
currentRow = 4 'Sheets(2).Range("A65536").End(xlUp).Row + 1
currentCol = 60
paramList = Array("LESS100", "LNA200 COOL", _
"LNA200 POWER", "MEGA100", _
"MEGA1000", "MEGA200", _
"MEGA500")
'Get Role(8) Location
For i = 1 To lastCol
If Sheets(1).Cells(6, i).Value = "Role (8)" Then
role8Loc = i
End If
Next i
'Get AC POWER (LVL1) Location
For i = role8Loc To lastCol
If Sheets(1).Cells(6, i).Value = "AC POWER (LVL1)" Then
acpowerLoc = i
End If
나는 그것이 필요하지 생각 파일 원인에 대한 전체 코드를 포함하지 않았다. 당신이해야
오류가 발생했을 때'role8Loc'의 값은 무엇입니까? –
@Robin Mackenzie 비어 있습니다. – nubcoder17
그게 문제입니다. 'role8Loc'은 Excel 버전에 따라 최대 열 수 1에서 최대 값 사이의 값이어야합니다. 이전 루프에서 'Role (8)'값을 가진 셀이 없었던 것 같습니다. 두 번째 루프를 실행하기 전에'role8Loc'을 검사하기 위해서는'If' 문이 필요합니다. HTH –