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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding a column based on cell contents 1

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
EU
Hi,

I have a MACRO that clears out the data from and repopulates a months worth of dates in a time sheet spreadsheet.

I need to hide the weekend columns, row 6 of each column is populated with the day of the week.

What I would like to do is loop through all of the columns in a given range and hide as appropriate, something like:
Code:
range = x to bb
For each column in range
If ((this_column:5 = 'Sat') or (this_column:5 = 'Sun') Then
hide column
End If
Next

Can some one help?

Cheech


[Peace][Pipe]
 

Hi,

Column is a reserve word.
Range is a reserve word.

Code:
dim rng as range, r as range
set rng = Range(Cells(6, "X"), Cells(6, "BB"))
For each r in rng
If (r.value = 'Sat') or (r.value = 'Sun') Then
  r.entirecolumn.hidden = true
End If
Next

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top