Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Change Whole Column Cell Color

How can I use VB to change the color of a whole column

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Change Whole Column Cell Color

Columns("F:F").Interior.ColorIndex = 40

--

HTH

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


"Nigel Bennett" wrote in message
...
How can I use VB to change the color of a whole column

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Change Whole Column Cell Color

Thanks Bob, if I can expand on it a bit, I know the cell I
am in for Example B3 how cn I xtract the column from that
to apply the color to the column, the reason I ask is
because I am doing an essbase retrieve and I have blank
columns, I have some code that finds each blank column (by
looking in a specific row and seeing if a cell is blank)
then it resizes the column, I also want it to color the
column but in this case the cell is only colored. Here is
the code I use

Set LastCol = Cells(5, Columns.Count).End(xlToLeft)
Set rng = Range(Cells(4, 4), LastCol)

For Each oCell In rng
If oCell = "" Then
oCell.ColumnWidth = 1.5
oCell.Interior.ColorIndex = 40
End If
Next oCell
-----Original Message-----
Columns("F:F").Interior.ColorIndex = 40

--

HTH

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


"Nigel Bennett" wrote in message
...
How can I use VB to change the color of a whole column

Thanks



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Change Whole Column Cell Color

Set LastCol = Cells(5, Columns.Count).End(xlToLeft)
Set rng = Range(Cells(4, 4), LastCol)

For Each oCell In rng
If oCell = "" Then
oCell.ColumnWidth = 1.5
oCell.EntireColumn.Interior.ColorIndex = 40
End If
Next oCell


--

HTH

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


"Nigel Bennett" wrote in message
...
Thanks Bob, if I can expand on it a bit, I know the cell I
am in for Example B3 how cn I xtract the column from that
to apply the color to the column, the reason I ask is
because I am doing an essbase retrieve and I have blank
columns, I have some code that finds each blank column (by
looking in a specific row and seeing if a cell is blank)
then it resizes the column, I also want it to color the
column but in this case the cell is only colored. Here is
the code I use

Set LastCol = Cells(5, Columns.Count).End(xlToLeft)
Set rng = Range(Cells(4, 4), LastCol)

For Each oCell In rng
If oCell = "" Then
oCell.ColumnWidth = 1.5
oCell.Interior.ColorIndex = 40
End If
Next oCell
-----Original Message-----
Columns("F:F").Interior.ColorIndex = 40

--

HTH

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


"Nigel Bennett" wrote in message
...
How can I use VB to change the color of a whole column

Thanks



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Change Whole Column Cell Color

Nigel,

No need to loop:

With Range("4:4").SpecialCells(xlCellTypeBlanks).Entire Column
.ColumnWidth = 1.5
.Interior.ColorIndex = 40
End With

Note that this will fail if there aren't any blank cells: use On Error
Resume Next before this code if there is any chance of that.

If there is a reason why you check the cells in both rows 4 and 5, then you
could continue to do so:

With Range("4:5").SpecialCells(xlCellTypeBlanks).Entire Column
.ColumnWidth = 1.5
.Interior.ColorIndex = 40
End With

HTH,
Bernie
MS Excel MVP

"Nigel Bennett" wrote in message
...
Thanks Bob, if I can expand on it a bit, I know the cell I
am in for Example B3 how cn I xtract the column from that
to apply the color to the column, the reason I ask is
because I am doing an essbase retrieve and I have blank
columns, I have some code that finds each blank column (by
looking in a specific row and seeing if a cell is blank)
then it resizes the column, I also want it to color the
column but in this case the cell is only colored. Here is
the code I use

Set LastCol = Cells(5, Columns.Count).End(xlToLeft)
Set rng = Range(Cells(4, 4), LastCol)

For Each oCell In rng
If oCell = "" Then
oCell.ColumnWidth = 1.5
oCell.Interior.ColorIndex = 40
End If
Next oCell
-----Original Message-----
Columns("F:F").Interior.ColorIndex = 40

--

HTH

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


"Nigel Bennett" wrote in message
...
How can I use VB to change the color of a whole column

Thanks



.





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
Change column color in chart when column value is over/under goal Excel Charts Charts and Charting in Excel 2 December 10th 07 11:08 PM
Excel: Syntax to change cell color based on color of another cell davew18 Excel Worksheet Functions 1 January 4th 07 01:24 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM
How do I change the color of the indicator cell in row and column Jim the Estimator Excel Worksheet Functions 1 July 27th 05 12:31 PM
Browse Forms Controls and change TextBox color based on cell color StefanW Excel Programming 2 November 21st 04 07:06 PM


All times are GMT +1. The time now is 01:15 AM.

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

About Us

"It's about Microsoft Excel"