Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Format Cell If Cell Not Blank

Currently I have an IF statement determining if a cell is populated. I would
like to provide formatting to that cell if it is populated. Can anyone help
figure out how to do both.

Here is the current If statement:

=IF('01-Length of Contract-Rollovers'!$G19="Change Management",'01-Length of
Contract-Rollovers'!C19,"")

Here is the type of formatting I would like to use:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Format Cell If Cell Not Blank

Much simpler to do it with conditional formatting unless doing it with code
is essential.

use a conditional format of cell value is greater than "" then apply the
formats you require

"TonyD" wrote:

Currently I have an IF statement determining if a cell is populated. I would
like to provide formatting to that cell if it is populated. Can anyone help
figure out how to do both.

Here is the current If statement:

=IF('01-Length of Contract-Rollovers'!$G19="Change Management",'01-Length of
Contract-Rollovers'!C19,"")

Here is the type of formatting I would like to use:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Format Cell If Cell Not Blank

Worksheet functions can't format cells, but you could use Conditional
Formatting in the cell.

CF1: =ISBLANK(xx) (where xx = the cell to be formatted)
Format1: <borders/<box, desired color

In article ,
TonyD wrote:

Currently I have an IF statement determining if a cell is populated. I would
like to provide formatting to that cell if it is populated. Can anyone help
figure out how to do both.

Here is the current If statement:

=IF('01-Length of Contract-Rollovers'!$G19="Change Management",'01-Length of
Contract-Rollovers'!C19,"")

Here is the type of formatting I would like to use:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Format Cell If Cell Not Blank

Got it backwards:

CF1: Formula is =xx<""

In article ,
JE McGimpsey wrote:

Worksheet functions can't format cells, but you could use Conditional
Formatting in the cell.

CF1: =ISBLANK(xx) (where xx = the cell to be formatted)
Format1: <borders/<box, desired color

In article ,
TonyD wrote:

Currently I have an IF statement determining if a cell is populated. I
would
like to provide formatting to that cell if it is populated. Can anyone help
figure out how to do both.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Format Cell If Cell Not Blank

Mike, that works for text cells but doesn't provide any formatting for date
or zero (o) value cells.

"Mike" wrote:

Much simpler to do it with conditional formatting unless doing it with code
is essential.

use a conditional format of cell value is greater than "" then apply the
formats you require

"TonyD" wrote:

Currently I have an IF statement determining if a cell is populated. I would
like to provide formatting to that cell if it is populated. Can anyone help
figure out how to do both.

Here is the current If statement:

=IF('01-Length of Contract-Rollovers'!$G19="Change Management",'01-Length of
Contract-Rollovers'!C19,"")

Here is the type of formatting I would like to use:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 15
End With


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
How do I make a blank cell with a date format blank? Pivot Table/Query Excel Worksheet Functions 6 June 14th 05 11:19 PM
Custom format that shows blank cell if another cell is empty Zdenek Moravec Excel Discussion (Misc queries) 1 March 25th 05 11:45 AM
Show Blank is cell value=0 but count as a zero in sum. How to format this cell ? Markus Obermayer Excel Discussion (Misc queries) 1 January 4th 05 08:01 PM
Show Blank is cell value=0 but count as a zero in sum. How to format this cell ? Markus Obermayer Excel Worksheet Functions 1 January 4th 05 08:01 PM
Show Blank is cell value=0 but count as a zero in sum. How to format this cell ? Markus Obermayer Excel Programming 2 January 4th 05 08:01 PM


All times are GMT +1. The time now is 04:50 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"