Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Highlight blank cells

I have multiple Excel files. Each one of them has a different number of
records in them. Some have alot some have very few.

I need to write in VB to highlight any cell that is blank. Could anyone
help me out?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Highlight blank cells

You can do this directly:

Sub ColorBlanks()
Dim Rng As Range
For Each Rng In Selection
With Rng
If .Value = vbNullString Then
.Interior.ColorIndex = 3 'red
Else
.Interior.ColorIndex = xlColorIndexAutomatic
End If
End With
Next Rng
End Sub

Select the cells to test then run the macro. As an alternative, you could
use Condition Formatting (CF). Select the cells to test, open the CF dialog
from the Format menu, change "Cell Value Is" to "Formula Is" and enter

=A1=""

Change A1 to the first selected cell and choose your formatting.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"pokdbz" wrote in message
...
I have multiple Excel files. Each one of them has a different number of
records in them. Some have alot some have very few.

I need to write in VB to highlight any cell that is blank. Could anyone
help me out?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Highlight blank cells

Selection.SpecialCells(xlCellTypeBlanks).Select

"pokdbz" skrev:

I have multiple Excel files. Each one of them has a different number of
records in them. Some have alot some have very few.

I need to write in VB to highlight any cell that is blank. Could anyone
help me out?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Highlight blank cells

Great
Is there a way to figure out what the range will be on its own without me
selecting it?

Row 1 will always have headings in it.
So is it possible to find out what the last column is an use that for the
selection criteria?

Also Column A will never be blank so can you use this info to automatically
select the range? so that it doesn't color the outside cells?

"Chip Pearson" wrote:

You can do this directly:

Sub ColorBlanks()
Dim Rng As Range
For Each Rng In Selection
With Rng
If .Value = vbNullString Then
.Interior.ColorIndex = 3 'red
Else
.Interior.ColorIndex = xlColorIndexAutomatic
End If
End With
Next Rng
End Sub

Select the cells to test then run the macro. As an alternative, you could
use Condition Formatting (CF). Select the cells to test, open the CF dialog
from the Format menu, change "Cell Value Is" to "Formula Is" and enter

=A1=""

Change A1 to the first selected cell and choose your formatting.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"pokdbz" wrote in message
...
I have multiple Excel files. Each one of them has a different number of
records in them. Some have alot some have very few.

I need to write in VB to highlight any cell that is blank. Could anyone
help me out?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Highlight blank cells

Would it be possible to incorporate the ctrl-shift-right and ctrl-shift-down
to select the edge of the regions?

"Chip Pearson" wrote:

You can do this directly:

Sub ColorBlanks()
Dim Rng As Range
For Each Rng In Selection
With Rng
If .Value = vbNullString Then
.Interior.ColorIndex = 3 'red
Else
.Interior.ColorIndex = xlColorIndexAutomatic
End If
End With
Next Rng
End Sub

Select the cells to test then run the macro. As an alternative, you could
use Condition Formatting (CF). Select the cells to test, open the CF dialog
from the Format menu, change "Cell Value Is" to "Formula Is" and enter

=A1=""

Change A1 to the first selected cell and choose your formatting.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"pokdbz" wrote in message
...
I have multiple Excel files. Each one of them has a different number of
records in them. Some have alot some have very few.

I need to write in VB to highlight any cell that is blank. Could anyone
help me out?


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
conditional formatting:highlight row based on blank or non-blank c Nat Maxwell Excel Worksheet Functions 3 May 14th 23 07:43 PM
Highlight cells where the last charcter in the cell is a blank Pat[_4_] Excel Worksheet Functions 5 February 27th 08 01:21 PM
conditional formatting:highlight row based on blank or non-blank c Nat Maxwell Excel Discussion (Misc queries) 2 November 30th 05 10:30 PM
highlight non blank cells in column Annette[_4_] Excel Programming 6 December 20th 04 09:42 PM
Highlight blank cells Rhonda[_3_] Excel Programming 4 December 4th 03 07:19 PM


All times are GMT +1. The time now is 12:36 PM.

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"