Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through a range of cells, but ignoring hidden cells 1

Status
Not open for further replies.

verdugan

Computer
Apr 10, 2007
3
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
 
Replies continue below

Recommended for you

If you dont view the hidden cells why worry?

You could also use conditional formatting.

Best regards

Morten
 
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
 
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
 
Nick,

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

Angel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor