D
Darin Kramer
Hi there,
I have a macro that looks at columns in a workbook, and if the colour in
line 189 matches the colour of the cell when the macro is run it leaves
the column visible. If the colour is different it hides the column.
It works perfectly up until about 5 minutes ago, when I get the subject
title error - It also works from column F until column GW - and then
gets stuck. Im no expert... so appreciate any advice.
The Macro that runs the colour hiding / not is shown below
Any ideas...??
Apprecaite the help....!!!
Kind Regards
D
Public Sub Colour_views()
Dim objWS As Excel.Worksheet
Dim objCell As Excel.Range, objR As Excel.Range
Dim i As Byte
Dim J As Long
Set objWS = Sheets("Master")
' Don't forget that wherever you're looking at, the selected cell needs
to have a background
' color that matches the various "views" you've built on the master
sheet.
Set objCell = Application.Selection
J = objCell.Interior.ColorIndex
' Hide columns
' If columns A - F are always going to be there, we only need to start
with Column E, which
' is column number 6.
For i = 6 To 223
Set objR = objWS.Cells(2, i) ' We'll always be looking at row 2 -
the column will change
If objR.Interior.ColorIndex <> J Then
objWS.Columns(i).Hidden = True
End If
Next
Set objR = Nothing
Set objCell = Nothing
Set objWS = Nothing
Sheets("master").Select
End Sub
I have a macro that looks at columns in a workbook, and if the colour in
line 189 matches the colour of the cell when the macro is run it leaves
the column visible. If the colour is different it hides the column.
It works perfectly up until about 5 minutes ago, when I get the subject
title error - It also works from column F until column GW - and then
gets stuck. Im no expert... so appreciate any advice.
The Macro that runs the colour hiding / not is shown below
Any ideas...??
Apprecaite the help....!!!
Kind Regards
D
Public Sub Colour_views()
Dim objWS As Excel.Worksheet
Dim objCell As Excel.Range, objR As Excel.Range
Dim i As Byte
Dim J As Long
Set objWS = Sheets("Master")
' Don't forget that wherever you're looking at, the selected cell needs
to have a background
' color that matches the various "views" you've built on the master
sheet.
Set objCell = Application.Selection
J = objCell.Interior.ColorIndex
' Hide columns
' If columns A - F are always going to be there, we only need to start
with Column E, which
' is column number 6.
For i = 6 To 223
Set objR = objWS.Cells(2, i) ' We'll always be looking at row 2 -
the column will change
If objR.Interior.ColorIndex <> J Then
objWS.Columns(i).Hidden = True
End If
Next
Set objR = Nothing
Set objCell = Nothing
Set objWS = Nothing
Sheets("master").Select
End Sub