×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Looping through a range of cells, but ignoring hidden cells

Looping through a range of cells, but ignoring hidden cells

Looping through a range of cells, but ignoring hidden cells

(OP)
Hello. First time poster here.  I searched, but couldn't find the answer.

I am looping through a range of cells, and I want to turn the empty cells red. However, I want to ignore hidden cells. I have figured out everything except the ignoring the hidden cells part.  I get "Unabele to get the Hidden propety of the Range class."

My code is:
For Each c In Range("C3:K" & rowLimit).Cells
    If (IsEmpty(c.Value)) AND (c.Hidden = FALSE)Then
        c.Interior.ColorIndex = 3
        End If
    End If
Next

Any help is much appreciated.  Thanks in advance.

Angel

RE: Looping through a range of cells, but ignoring hidden cells

If you dont view the hidden cells why worry?

You could also use conditional formatting.

Best regards

Morten

RE: Looping through a range of cells, but ignoring hidden cells

The Hidden property applies to entire rows and columns, so you might try:

Dim c As Range

For Each c In Range("C3:K" & rowLimit).Cells
    If (Not c.EntireColumn.Hidden) And (Not c.EntireRow.Hidden) Then
        If IsEmpty(c.Value) Then
            ' Perform action
        End If
    End If
Next


-- Nick

RE: Looping through a range of cells, but ignoring hidden cells

(OP)
Morten,
Thanks for the reply.  I'm processing the file and if there are any empty cells, I abort the process.  But I don't care if any hidden cells are empty.
I tried conditional formatting, but I only want empty cells red at final processing.  I do not know a way to turn on/off conditional formatting.

Angel

RE: Looping through a range of cells, but ignoring hidden cells

(OP)
Nick,

TVM for your reply.  "The Hidden property applies to entire rows and columns"  That was obviously the problem.  It's working now.

Angel

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources