Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default color hidden columns

Sorry for the newbie (in programming anyway) question.

I have found a great macro for colouring hidden rows from Andrew Engwirda
which I have copied below. Could some kind programming guru help me
transform it in to a macro to colour hidden columns.
Thanks in advance,
Barbara
(from my spelling of colour, you may guess I am from the UK)

http://blog.livedoor.jp/andrewe/archives/13105945.html

Sub ColorHiddenRows()
On Error GoTo Terminator
Dim rw As Range
Dim fstrw As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
Set myRange = Selection
For Each rw In myRange.Rows
If rw.Hidden = True Then
If fstrw Is Nothing Then
Set fstrw = rw
Exit For
End If
End If
Next
fstrw.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each rw In myRange.Rows
If rw.Hidden = True Then
rw.Interior.ColorIndex = myColor
rw.Interior.Pattern = myPattern
rw.Interior.PatternColorIndex = myPatternColor
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden rows ", vbExclamation
End Sub





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default color hidden columns

One way:

Option Explicit
Sub ColorHiddenCols()
On Error GoTo Terminator
Dim Col As Range
Dim fstCol As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
Set myRange = Selection
For Each Col In myRange.Columns
If Col.Hidden = True Then
If fstCol Is Nothing Then
Set fstCol = Col
Exit For
End If
End If
Next
fstCol.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each Col In myRange.Columns
If Col.Hidden = True Then
Col.Interior.ColorIndex = myColor
Col.Interior.Pattern = myPattern
Col.Interior.PatternColorIndex = myPatternColor
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden columns ", vbExclamation
End Sub





Barbara Wiseman wrote:

Sorry for the newbie (in programming anyway) question.

I have found a great macro for colouring hidden rows from Andrew Engwirda
which I have copied below. Could some kind programming guru help me
transform it in to a macro to colour hidden columns.
Thanks in advance,
Barbara
(from my spelling of colour, you may guess I am from the UK)

http://blog.livedoor.jp/andrewe/archives/13105945.html

Sub ColorHiddenRows()
On Error GoTo Terminator
Dim rw As Range
Dim fstrw As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
Set myRange = Selection
For Each rw In myRange.Rows
If rw.Hidden = True Then
If fstrw Is Nothing Then
Set fstrw = rw
Exit For
End If
End If
Next
fstrw.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each rw In myRange.Rows
If rw.Hidden = True Then
rw.Interior.ColorIndex = myColor
rw.Interior.Pattern = myPattern
rw.Interior.PatternColorIndex = myPatternColor
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden rows ", vbExclamation
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default color hidden columns

Sub ColorHiddenColumns()
On Error GoTo Terminator
Dim rw As Range
Dim fstrw As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
Set myRange = Selection
For Each rw In myRange.Columns
If rw.Hidden = True Then
If fstrw Is Nothing Then
Set fstrw = rw
Exit For
End If
End If
Next
fstrw.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each rw In myRange.Columns
If rw.Hidden = True Then
rw.Interior.ColorIndex = myColor
rw.Interior.Pattern = myPattern
rw.Interior.PatternColorIndex = myPatternColor
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden rows ", vbExclamation
End Sub

--
Regards,
Tom Ogilvy



"Barbara Wiseman" wrote in message
...
Sorry for the newbie (in programming anyway) question.

I have found a great macro for colouring hidden rows from Andrew Engwirda
which I have copied below. Could some kind programming guru help me
transform it in to a macro to colour hidden columns.
Thanks in advance,
Barbara
(from my spelling of colour, you may guess I am from the UK)

http://blog.livedoor.jp/andrewe/archives/13105945.html

Sub ColorHiddenRows()
On Error GoTo Terminator
Dim rw As Range
Dim fstrw As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
Set myRange = Selection
For Each rw In myRange.Rows
If rw.Hidden = True Then
If fstrw Is Nothing Then
Set fstrw = rw
Exit For
End If
End If
Next
fstrw.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each rw In myRange.Rows
If rw.Hidden = True Then
rw.Interior.ColorIndex = myColor
rw.Interior.Pattern = myPattern
rw.Interior.PatternColorIndex = myPatternColor
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden rows ", vbExclamation
End Sub







  #4   Report Post  
Posted to microsoft.public.excel.programming
ste ste is offline
external usenet poster
 
Posts: 18
Default color hidden columns

hi,
change myRange.Rows in myRange.Columns. easy, isn't it?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default color hidden columns

Here you are Barabra, as requested, although I am at a loss as to know what
use it is to colour hidden columns? Also, be aware that there are a lot more
rows than columns, so by colouring a whole column, you are in creasing the
size of a workbook far more than by colouring a row.

Sub ColourHiddenColumns()
On Error GoTo Terminator
Dim cw As Range
Dim fstcw As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
For Each cw In ActiveSheet.UsedRange.Columns
If cw.Hidden = True Then
If fstcw Is Nothing Then
Set fstcw = cw
Exit For
End If
End If
Next
fstcw.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each cw In ActiveSheet.UsedRange.Columns
If cw.Hidden = True Then
With cw.EntireColumn.Interior
.ColorIndex = myColor
.Pattern = myPattern
.PatternColorIndex = myPatternColor
End With
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden columns ", vbExclamation
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Barbara Wiseman" wrote in message
...
Sorry for the newbie (in programming anyway) question.

I have found a great macro for colouring hidden rows from Andrew Engwirda
which I have copied below. Could some kind programming guru help me
transform it in to a macro to colour hidden columns.
Thanks in advance,
Barbara
(from my spelling of colour, you may guess I am from the UK)

http://blog.livedoor.jp/andrewe/archives/13105945.html

Sub ColorHiddenRows()
On Error GoTo Terminator
Dim rw As Range
Dim fstrw As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
Set myRange = Selection
For Each rw In myRange.Rows
If rw.Hidden = True Then
If fstrw Is Nothing Then
Set fstrw = rw
Exit For
End If
End If
Next
fstrw.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each rw In myRange.Rows
If rw.Hidden = True Then
rw.Interior.ColorIndex = myColor
rw.Interior.Pattern = myPattern
rw.Interior.PatternColorIndex = myPatternColor
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden rows ", vbExclamation
End Sub









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default color hidden columns

Tom,
Your solution worked on my spreadsheet, thank you so much.
As to why I would want to colour hidden columns. We get spreadsheets from
other people in the company, and instead of grouping columns or rows which
they do not want to show, which is always my preference, they hide them. I
sometimes need to see this information and then get the spreadsheet back to
the state it was in to start with. I now realise that colouring the columns
will inflate the spreadsheet size, and have thought of another method. This
is to have a spare row at the top somewhere, highlight all the cells in that
row on top of the data, F5, special, visible cells only (or use the toolbar
icon) and colour these. When the columns are unhidden the unhidden columns
are uncoloured on this row.
Thanks to all who have given their time to help.
Barbara

Tom Ogilvy wrote:
Sub ColorHiddenColumns()
On Error GoTo Terminator
Dim rw As Range
Dim fstrw As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
Set myRange = Selection
For Each rw In myRange.Columns
If rw.Hidden = True Then
If fstrw Is Nothing Then
Set fstrw = rw
Exit For
End If
End If
Next
fstrw.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each rw In myRange.Columns
If rw.Hidden = True Then
rw.Interior.ColorIndex = myColor
rw.Interior.Pattern = myPattern
rw.Interior.PatternColorIndex = myPatternColor
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden rows ", vbExclamation
End Sub


"Barbara Wiseman" wrote in message
...
Sorry for the newbie (in programming anyway) question.

I have found a great macro for colouring hidden rows from Andrew
Engwirda which I have copied below. Could some kind programming
guru help me transform it in to a macro to colour hidden columns.
Thanks in advance,
Barbara
(from my spelling of colour, you may guess I am from the UK)

http://blog.livedoor.jp/andrewe/archives/13105945.html

Sub ColorHiddenRows()
On Error GoTo Terminator
Dim rw As Range
Dim fstrw As Range
Dim myRange As Range
Dim myColor As Long
Dim myPattern As Long
Dim myPatternColor As Long
Set myRange = Selection
For Each rw In myRange.Rows
If rw.Hidden = True Then
If fstrw Is Nothing Then
Set fstrw = rw
Exit For
End If
End If
Next
fstrw.Select
Application.Dialogs(xlDialogPatterns).Show
myColor = ActiveCell.Interior.ColorIndex
myPattern = ActiveCell.Interior.Pattern
myPatternColor = ActiveCell.Interior.PatternColorIndex
For Each rw In myRange.Rows
If rw.Hidden = True Then
rw.Interior.ColorIndex = myColor
rw.Interior.Pattern = myPattern
rw.Interior.PatternColorIndex = myPatternColor
End If
Next
Exit Sub
Terminator: MsgBox "There are no hidden rows ", vbExclamation
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Worksheet, Hidden Columns, .CSV Format Saves Hidden Column Da Tammy Excel Discussion (Misc queries) 3 April 2nd 09 11:40 PM
Copy and Paste with hidden columns remaining hidden Pendelfin Excel Discussion (Misc queries) 2 February 26th 09 11:35 AM
Hidden rows columns won't stay hidden christie Excel Worksheet Functions 0 September 30th 08 05:44 PM
Hidden Columns No Longer Hidden after Copying Worksheet? EV Nelson Excel Discussion (Misc queries) 1 December 6th 06 05:10 PM
How to keep hidden columns hidden using protection Dave Excel Discussion (Misc queries) 1 March 1st 06 02:20 AM


All times are GMT +1. The time now is 10:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"