Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

The Cells(row, column) property counts hidden columns 1

Status
Not open for further replies.

cardiac

Technical User
Feb 19, 2004
31
0
0
GB
I'm writing a workload planner for all the departments at my office. Each dept. is represented by a column. As there are several admin staff, each responsible for a different group of depts., I hide the irrelevant columns (depts.) depending on which admin member has opened the file.

The problem occurs when I use a loop to iterate through all the visible columns and check whether the cell contains a 'Y' or a 'N' (whether the latest piece of work affects this dept. or not). I use a loop like the following:

Code:
  For i = 1 to intNumberOfDepts
            'intRow & intCol are defined elsewhere
            strAffected = sheet1.Cells(intRow, intCol + i)
            If strAffected = "Y" Then . . . 
            ElseIf strAffected = "N" Then . . .
            Else  . . .
            End If
        Next i

I need the loop to ignore the hidden columns and just process the visible ones, but the Cells property counts them all!

Is there a way 'round this?

Many thanks,

David
 
Look at the SpecialCells(xlCellTypeVisible) method.

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top