Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I use VB to change the color of a whole column
Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Change column color in chart when column value is over/under goal | Charts and Charting in Excel | |||
Excel: Syntax to change cell color based on color of another cell | Excel Worksheet Functions | |||
How to change the default Border, Font Color, and Cell Color | Excel Discussion (Misc queries) | |||
How do I change the color of the indicator cell in row and column | Excel Worksheet Functions | |||
Browse Forms Controls and change TextBox color based on cell color | Excel Programming |