PDA

View Full Version : [SOLVED:] Object Required Error in UnHiding rows



simora
10-23-2020, 01:42 PM
I am trying to unhide all hidden rows in a range in ActiveSheet.Range("A4:A93")
For each of those hidden ranges, when it now becomes visible, I want the Cell in Column A once it's now visible / unHidden to be shaded Interior.colorIndex = 19
I'm getting an error in the [PROBLEM] lines, An Object Required Error

I've tried using Row & Cell etc..etc... but I'm still getting an error



For Each Row In ActiveSheet.Range("A4:A93")
If Row.EntireRow.Hidden = True Then
[PROBLEM] EntireRow.Hidden = False
[PROBLEM] EntireRow.Interior.colorIndex = 19

Paul_Hossler
10-23-2020, 02:13 PM
Not tested, and done from memory

"Row" is a VBA key word, but I think the real problem was that "EntireRow" was not qualified, i.e. it should have been something like rCell.EntireRow

Try



For Each rCell In ActiveSheet.Range("A4:A93").Cells
With rCell.EntireRow
If .Hidden Then
.Hidden = False
.Interior.colorIndex = 19
End If
End With
Next

simora
10-23-2020, 09:14 PM
Thanks Paul_Hossler (http://www.vbaexpress.com/forum/member.php?9803-Paul_Hossler)

It worked. You are correct. "EntireRow" was not qualified, and also apparently,
You cannot call the EntireRow.Hidden from the Cell object as I was attempting in my other trials.
Sleep does wonders for the brain !
Thank you.

simora
10-23-2020, 10:19 PM
What is the best way to modify this so that only the cells in Column A are shaded .Interior.colorIndex = 19

p45cal
10-24-2020, 02:24 AM
.cells (1).interior.colorindex = 19

Paul_Hossler
10-24-2020, 08:17 AM
Probably something like this




For Each rCell In ActiveSheet.Range("A4:A93").Cells
With rCell
If .EntireRow.Hidden Then .EntireRow.Hidden = False .Interior.colorIndex = 19
End If
End With Next

simora
10-24-2020, 02:24 PM
Paul_Hossler (http://www.vbaexpress.com/forum/member.php?9803-Paul_Hossler) & p45cal
(http://www.vbaexpress.com/forum/member.php?3494-p45cal)
Thanks guys.
Everything worked as expected.