View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Haldun Alay[_2_] Haldun Alay[_2_] is offline
external usenet poster
 
Posts: 16
Default Problem with IsEmpty Function

Hi,

Did you try cell.value="None"

It works with your code. But it's better to use Excel's
SpecialCells(xlCellTypeBlanks) future. I use following macro to fill up
blank cells in selection with zeros. May be it helps to you.

Sub FillZero()
Dim cll
Dim slct
On Error GoTo ErrorHandler:
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
If TypeName(Selection) = "Range" Then
Set slct = Selection.SpecialCells(xlCellTypeBlanks)
slct.Value = 0
End If
ErrorHandler:
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub



Haldun



"Matt" , iletide sunu yazdi
om...
Hi all,

I have a small script that formats and emails a simple spreadsheet.
However, I am having a small problem getting one part of the script to
work correctly.

Column D of the spreadsheet contains various IDs and I want the script
to change those IDs to the corresponding user's initials. However, it
is possible that this column could contain blank cells and, if so, I
want the script to change the text of the cell to "NONE". The code
looks like this so far :-

For Each Cell In Range(Range("D2"), Range("D2").End(xlDown))
If IsEmpty(Cell) = True Then Cell = "None"
If Cell = "idxxxx" Then Cell = "foo"
If Cell = "idxxxx" Then Cell = "foo"
If Cell = "idxxxxx" Then Cell = "foo"
Next

What happens is that that the script runs and appears to work
correctly. However, when I check the spreadsheet I see that all cells
that are BEFORE the first blank cell are changed and any cells
including and following the blank cell are not changed.

I've tried using IsEmpty and IsNull and neither work.

Any ideas?