View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John[_88_] John[_88_] is offline
external usenet poster
 
Posts: 205
Default Macro to Set width of cells

Hi Derk,

Have a go with the code below.

Regards

John



Sub WeekendHide()

Dim iRow As Long
Dim iCol As Long

If MsgBox("Is currently selected cell at beginning of month?", _
vbYesNo + vbQuestion, _
"Check start") = vbNo Then Exit Sub

iCol = ActiveCell.Column
iRow = ActiveCell.Row

Do Until iCol = 31
Debug.Print iCol
If Cells(iRow, iCol).Value = "Saturday" Or _
Cells(iRow, iCol).Value = "Sunday" Then
Columns(iCol).Hidden = True
End If
iCol = iCol + 1
Loop

MsgBox ("Weekend colums hidden.")

End Sub


"Derk" wrote in message
...
I have a sheet with days of the week in the heading, for a month. I would
like to hide the col if it is a Saturday or Sunday. I am working on trying
to write a macro to check the value of B3 to B34 (which contains the date
and see if it contains Sat or Sun and then set the col width to zero.
Thats
the theory, but am stuck with the code required to get the check each cell
then set the width

Thamnks


Derrick