Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Searching for empty cells and changing values

I have a worksheet that contains sample results for chemical analysis.

Not all analytes are analyzed each time, thus some of the cells are empty.

To make the graphs more usable, I want to search the data range for empty
cells and place =NA() in them so that the trend lines and continuous.

Here's what I have been trying...
For Each cl In Worksheets("Data").Range("A2:AC" & LastRowUsed).Cells
If cl.Value = "" Then
cl.Value = "=NA()"
End If
Next

Each time I have tried this, the code errors out on me when it reaches a
cell that already has the value set to =NA().

Is there a better approach to what I'm attempting, perhaps a way to set a
command to do the entire range at once, instead of evaluating each cell?

Thanks in advance, and HAPPY HALLOWEEN.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Searching for empty cells and changing values

Hi,

Test for an error

For Each cl In Worksheets("Data").Range("A2:AC" & 5).Cells
If Not IsError(cl.Value) Then
If cl.Value = "" Then
cl.Value = "=NA()"
End If
End If
Next

Mike

"PosseJohn" wrote:

I have a worksheet that contains sample results for chemical analysis.

Not all analytes are analyzed each time, thus some of the cells are empty.

To make the graphs more usable, I want to search the data range for empty
cells and place =NA() in them so that the trend lines and continuous.

Here's what I have been trying...
For Each cl In Worksheets("Data").Range("A2:AC" & LastRowUsed).Cells
If cl.Value = "" Then
cl.Value = "=NA()"
End If
Next

Each time I have tried this, the code errors out on me when it reaches a
cell that already has the value set to =NA().

Is there a better approach to what I'm attempting, perhaps a way to set a
command to do the entire range at once, instead of evaluating each cell?

Thanks in advance, and HAPPY HALLOWEEN.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Searching for empty cells and changing values

OOPS I changed you variable LastRowUsed to a number to save me from
populating it so change it back

"Mike H" wrote:

Hi,

Test for an error

For Each cl In Worksheets("Data").Range("A2:AC" & 5).Cells
If Not IsError(cl.Value) Then
If cl.Value = "" Then
cl.Value = "=NA()"
End If
End If
Next

Mike

"PosseJohn" wrote:

I have a worksheet that contains sample results for chemical analysis.

Not all analytes are analyzed each time, thus some of the cells are empty.

To make the graphs more usable, I want to search the data range for empty
cells and place =NA() in them so that the trend lines and continuous.

Here's what I have been trying...
For Each cl In Worksheets("Data").Range("A2:AC" & LastRowUsed).Cells
If cl.Value = "" Then
cl.Value = "=NA()"
End If
Next

Each time I have tried this, the code errors out on me when it reaches a
cell that already has the value set to =NA().

Is there a better approach to what I'm attempting, perhaps a way to set a
command to do the entire range at once, instead of evaluating each cell?

Thanks in advance, and HAPPY HALLOWEEN.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Searching for empty cells and changing values

Thanks Mike.

"Mike H" wrote:

OOPS I changed you variable LastRowUsed to a number to save me from
populating it so change it back

"Mike H" wrote:

Hi,

Test for an error

For Each cl In Worksheets("Data").Range("A2:AC" & 5).Cells
If Not IsError(cl.Value) Then
If cl.Value = "" Then
cl.Value = "=NA()"
End If
End If
Next

Mike

"PosseJohn" wrote:

I have a worksheet that contains sample results for chemical analysis.

Not all analytes are analyzed each time, thus some of the cells are empty.

To make the graphs more usable, I want to search the data range for empty
cells and place =NA() in them so that the trend lines and continuous.

Here's what I have been trying...
For Each cl In Worksheets("Data").Range("A2:AC" & LastRowUsed).Cells
If cl.Value = "" Then
cl.Value = "=NA()"
End If
Next

Each time I have tried this, the code errors out on me when it reaches a
cell that already has the value set to =NA().

Is there a better approach to what I'm attempting, perhaps a way to set a
command to do the entire range at once, instead of evaluating each cell?

Thanks in advance, and HAPPY HALLOWEEN.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Searching for empty cells and changing values


your welcome
"PosseJohn" wrote:

Thanks Mike.

"Mike H" wrote:

OOPS I changed you variable LastRowUsed to a number to save me from
populating it so change it back

"Mike H" wrote:

Hi,

Test for an error

For Each cl In Worksheets("Data").Range("A2:AC" & 5).Cells
If Not IsError(cl.Value) Then
If cl.Value = "" Then
cl.Value = "=NA()"
End If
End If
Next

Mike

"PosseJohn" wrote:

I have a worksheet that contains sample results for chemical analysis.

Not all analytes are analyzed each time, thus some of the cells are empty.

To make the graphs more usable, I want to search the data range for empty
cells and place =NA() in them so that the trend lines and continuous.

Here's what I have been trying...
For Each cl In Worksheets("Data").Range("A2:AC" & LastRowUsed).Cells
If cl.Value = "" Then
cl.Value = "=NA()"
End If
Next

Each time I have tried this, the code errors out on me when it reaches a
cell that already has the value set to =NA().

Is there a better approach to what I'm attempting, perhaps a way to set a
command to do the entire range at once, instead of evaluating each cell?

Thanks in advance, and HAPPY HALLOWEEN.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Searching for empty cells and changing values

I think you could do this without a loop using a single statement...

Worksheets("Data").Range("A2:AC" & LastRowUsed). _
SpecialCells(xlCellTypeBlanks).Formula="=NA()"

--
Rick (MVP - Excel)


"Mike H" wrote in message
...
OOPS I changed you variable LastRowUsed to a number to save me from
populating it so change it back

"Mike H" wrote:

Hi,

Test for an error

For Each cl In Worksheets("Data").Range("A2:AC" & 5).Cells
If Not IsError(cl.Value) Then
If cl.Value = "" Then
cl.Value = "=NA()"
End If
End If
Next

Mike

"PosseJohn" wrote:

I have a worksheet that contains sample results for chemical analysis.

Not all analytes are analyzed each time, thus some of the cells are
empty.

To make the graphs more usable, I want to search the data range for
empty
cells and place =NA() in them so that the trend lines and continuous.

Here's what I have been trying...
For Each cl In Worksheets("Data").Range("A2:AC" &
LastRowUsed).Cells
If cl.Value = "" Then
cl.Value = "=NA()"
End If
Next

Each time I have tried this, the code errors out on me when it reaches
a
cell that already has the value set to =NA().

Is there a better approach to what I'm attempting, perhaps a way to set
a
command to do the entire range at once, instead of evaluating each
cell?

Thanks in advance, and HAPPY HALLOWEEN.


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
searching 2 values from 2 cells Steve Excel Discussion (Misc queries) 5 January 25th 10 07:45 PM
skip cells with zero values in chart (cells not empty) jhall@ifox Charts and Charting in Excel 3 June 2nd 09 02:11 PM
Defauls Values In Empty Cells chrysler265 New Users to Excel 1 February 16th 07 03:10 PM
How to select cells with values only (not empty ones)? nick Excel Discussion (Misc queries) 4 December 20th 06 09:07 PM
How to select cells with values only (not empty ones)? nick Excel Discussion (Misc queries) 1 December 20th 06 06:03 PM


All times are GMT +1. The time now is 03:00 PM.

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"