Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem with IsEmpty Function

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Problem with IsEmpty Function

Perhaps try

If Cell = "" then Cell ="None"

Jesse


"Matt" wrote in message
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?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Problem with IsEmpty Function

The range that is being searched extends down only to the first cell
above the first blank. Try

Range(Range("D65536"), Range("D65536").End(xlUp)

Alan Beban

Matt wrote:
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?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Problem with IsEmpty Function

The range that is being searched extends down only to the first cell
above the first blank. Try

Range(Range("D65536"), Range("D65536").End(xlUp))

Alan Beban

Matt wrote:
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?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem with IsEmpty Function

Alan Beban wrote in message ...
The range that is being searched extends down only to the first cell
above the first blank. Try

Range(Range("D65536"), Range("D65536").End(xlUp))

Alan Beban


No. All that will do is change every cell in Column D of the
worksheet to say "None" apart from the ones that have login ids in
them. However, you did point me in the right direction as I didn't
realise the range extended only to the first blank cell. I fixed it
by determining the last row used and explicity stating the range to be
used. I also changed the IF loop to a Select/Case loop. Here's the
new code :-

RowCount = Range("a1").CurrentRegion.Rows.Count
LastRow = "D" & RowCount

'Change idxxxxx values to ticket owner initials.

For Each Cell In Range(Range(LastRow), Range("D2").End(xlUp))
Select Case Cell
Case (IsNull(Cell))
Cell = "None"
Case "idxxx"
Cell = "foo"
Case "idxxx"
Cell = "foo"
...
...
...
End Select
Next

This works perfectly now.

Cheers,

Matt


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Problem with IsEmpty Function

Of course! It should have been

Range(Range("D2"), Range("D65536").End(xlUp))

The point was to come up from the bottom rather than go down from the
top (which was stopping before the first blank).

Sorry,
Alan Beban

Matt wrote:
Alan Beban wrote in message ...

The range that is being searched extends down only to the first cell
above the first blank. Try

Range(Range("D65536"), Range("D65536").End(xlUp))

Alan Beban



No. All that will do is change every cell in Column D of the
worksheet to say "None" apart from the ones that have login ids in
them. However, you did point me in the right direction as I didn't
realise the range extended only to the first blank cell. I fixed it
by determining the last row used and explicity stating the range to be
used. I also changed the IF loop to a Select/Case loop. Here's the
new code :-

RowCount = Range("a1").CurrentRegion.Rows.Count
LastRow = "D" & RowCount

'Change idxxxxx values to ticket owner initials.

For Each Cell In Range(Range(LastRow), Range("D2").End(xlUp))
Select Case Cell
Case (IsNull(Cell))
Cell = "None"
Case "idxxx"
Cell = "foo"
Case "idxxx"
Cell = "foo"
...
...
...
End Select
Next

This works perfectly now.

Cheers,

Matt


  #7   Report Post  
Posted to microsoft.public.excel.programming
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?



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
Need a function for problem steel108 Excel Worksheet Functions 2 July 7th 10 07:36 PM
Loop Statement through If Not IsEmpty Then Paste into Destination Dandelo Excel Discussion (Misc queries) 7 July 15th 08 10:29 PM
Form If IsEmpty Syntax Gizmo Excel Discussion (Misc queries) 4 May 25th 08 03:50 PM
IF function problem dvonj Excel Worksheet Functions 13 March 10th 05 01:13 PM
IsEmpty and Is Nothinq problems Stuart[_5_] Excel Programming 12 August 29th 03 06:13 AM


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