View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Enter "Empty" if cell is blank within a variable range

Hi Alatl,

Try somethimg like:

'================
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Const sStr As String = "Empty"

Set WB = Workbooks("MyBook.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet1") '<<===== CHANGE

With SH
On Error Resume Next
Set Rng = Intersect(.UsedRange, .Columns("A:B")). _
SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
End With

If Not Rng Is Nothing Then
Rng.Value = sStr
End If
End Sub
'<<================

---
Regards,
Norman


"ALATL" wrote in message
...
As simple as this sounds, I can't seem to make this work. I am looking for
code for the following:

I would like to enter the word "Empty" into a cell if the cell is blank.
The
range can be variable. The only columns that contain an empty cell are
columns B or C which can have any number of rows.

I appreciate any suggestions.

Best.