
Originally Posted by
ByteMarks
Does it work if you hide the rows?
I created named ranges for all of the hideable areas.
In a module I added a sub to hide the rows based on the input sheet.
A change even in the input sheet runs the sub in the module.
Wow this works seamlessly in that spreadsheet! So I tried moving this code over to my active spreadsheet where there are of course more documents. I'm getting an error whenever I change the value of "Good to be shipped" in my active spreadsheet. It should be noted that I'm entering the data on the "Input" tab and the # of Goods cell value is in cell I26, so I changed that range in the code as well.
The error I'm getting is: "Method 'Range' of object'_Global' failed
Which points to this area in the code:
Sub AdjustRows(NumGoods As Integer)
a = Array("CI_HIDE", "PL_HIDE1", "PL_HIDE2", "PL_HIDE3", "SR_HIDE", "SR_HIDE1", "SR_HIDE2", "SR_HIDE3", "SR_HIDE4", "CC_HIDE", "CC_HIDE1", "CC_HIDE2", "CC_HIDE3", "SBOL_HIDE", "AN_HIDE")
For i = 0 To UBound(a)
With Range(a(i))
.Rows.Hidden = False
Select Case NumGoods
Case 1 To 5
r = NumGoods + 1
.Rows(r & ":6").EntireRow.Hidden = True
End Select
End With
Next
End Sub
This is what I changed the private sub code to:
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Address = "$I$21" Then
Select Case .Value
Case 1 To 6
Call AdjustRows(.Value)
End Select
End If
End With
End Sub
Can you see what has gone wrong here by chance?
Bookmarks