I'm assuming that this question has been asked many a-time, but hopefully mine is a bit different.
I'm having issues correcting a 1004 runtime error. I've tried moving the code to and from module to worksheet, neither changed anything. I cannot really see how I'm meant to rephrase the loop which it is apparently failing at
Sub ProgramHideCycle()
Dim PROGGRAPH As Worksheet
Dim Project As Excel.Workbook
Dim Cell As Range
Dim CharPos(1 To 3) As Integer
Dim ValueENERGCount As Integer
Dim ValueCONSUCount As Integer
Dim ValueCONTRCount As Integer
ValueENERGCount = 0
ValueCONSUCount = 0
ValueCONTRCount = 0
Set Project = ThisWorkbook
With Project
Set PROGGRAPH = .Sheets("Program Graph")
For Each Cell In PROGGRAPH.Range(A5, A93)
CharPos(1) = InStr(1, Cell.Value, "ENERG")
CharPos(2) = InStr(1, Cell.Value, "CONTR")
CharPos(3) = InStr(1, Cell.Value, "CONSU")
If CharPos(1) < 0 Then
ValueENERGCount = 1
ElseIf CharPos(2) < 0 Then
ValueCONTRCount = 1
ElseIf CharPos(3) < 0 Then
ValueCONSUCount = 1
Else
Cell.EntireRow.Hidden = (Cell.Value = 0 Or Cell.Value = "")
End If
Next Cell
End With
End Sub
The code apparently fails at the beginning of the 'for' loop, yet attempting to change that doesn't seem to do anything. I'm likely missing something glaringly obvious, thanks for your help in advance.
尝试:
PROGGRAPH.Range("A5", "A93")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.