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

Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1 = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1
Else
End If
Next

I keep getting an error with the above code. It is not
seeing the #N/A error correctly. There are formulas all
in range O2:O100. How would I make this work?

Thank you

Todd Huttenstine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Loop Problem

Hi Todd,

Try this

Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1.Value = CVErr(xlErrNA) Then
Sheets("Mismatches").Range("A:" & Sheets("Mismatches").Range("H2").Value) =
cell1
Else
End If
Next

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine" wrote in message
...
Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1 = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1
Else
End If
Next

I keep getting an error with the above code. It is not
seeing the #N/A error correctly. There are formulas all
in range O2:O100. How would I make this work?

Thank you

Todd Huttenstine



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Loop Problem

Still getting that error.



-----Original Message-----
Hi Todd,

Try this

Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1.Value = CVErr(xlErrNA) Then
Sheets("Mismatches").Range("A:" & Sheets

("Mismatches").Range("H2").Value) =
cell1
Else
End If
Next

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine"

wrote in message
...
Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1 = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1
Else
End If
Next

I keep getting an error with the above code. It is not
seeing the #N/A error correctly. There are formulas all
in range O2:O100. How would I make this work?

Thank you

Todd Huttenstine



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop Problem

Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
if iserror(cell1) then
If cell1.Text = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets _
("Mismatches").Range("H2").Value) = cell1
End if
End If
Next

--
Regards,
Tom Ogilvy

"Todd Huttenstine" wrote in message
...
Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1 = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1
Else
End If
Next

I keep getting an error with the above code. It is not
seeing the #N/A error correctly. There are formulas all
in range O2:O100. How would I make this work?

Thank you

Todd Huttenstine



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Loop Problem

Well its looping through correctly, but then when it finds
a cell that equals the #N/A error, it hits the following
line of code...

Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1

I get the error Runtime error 1004 Application defined or
object defined error.



-----Original Message-----
Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
if iserror(cell1) then
If cell1.Text = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets _
("Mismatches").Range("H2").Value) = cell1
End if
End If
Next

--
Regards,
Tom Ogilvy

"Todd Huttenstine"

wrote in message
...
Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1 = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1
Else
End If
Next

I keep getting an error with the above code. It is not
seeing the #N/A error correctly. There are formulas all
in range O2:O100. How would I make this work?

Thank you

Todd Huttenstine



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop Problem

Does H2 contain a value between 1 and 65536 inclusive?

It sounds like it doesn't.
Based on your code, I would guess that H2 contains a formula like

=CountA(A1:A65536)+1

if you want to progressively accumulate your values (although it seems like
all you would get would be the #N/A entered as text in the cell)

Which should always have at least a value of 1, but that would only be a
guess - since you are having problems, perhaps not.
--
Regards,
Tom Ogilvy


"Todd Huttenstine" wrote in message
...
Well its looping through correctly, but then when it finds
a cell that equals the #N/A error, it hits the following
line of code...

Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1

I get the error Runtime error 1004 Application defined or
object defined error.



-----Original Message-----
Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
if iserror(cell1) then
If cell1.Text = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets _
("Mismatches").Range("H2").Value) = cell1
End if
End If
Next

--
Regards,
Tom Ogilvy

"Todd Huttenstine"

wrote in message
...
Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1 = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1
Else
End If
Next

I keep getting an error with the above code. It is not
seeing the #N/A error correctly. There are formulas all
in range O2:O100. How would I make this work?

Thank you

Todd Huttenstine



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Loop Problem

Todd,

remove the ":" after "A"


In article ,
"Todd Huttenstine" wrote:

Well its looping through correctly, but then when it finds
a cell that equals the #N/A error, it hits the following
line of code...

Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1

I get the error Runtime error 1004 Application defined or
object defined error.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop Problem

Good catch - I missed that.

--
Regards,
Tom Ogilvy

"JE McGimpsey" wrote in message
...
Todd,

remove the ":" after "A"


In article ,
"Todd Huttenstine" wrote:

Well its looping through correctly, but then when it finds
a cell that equals the #N/A error, it hits the following
line of code...

Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1

I get the error Runtime error 1004 Application defined or
object defined error.



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Loop Problem

Ah thanx that did it.


Appreciate everyones help.

Have a good day!
-----Original Message-----
Todd,

remove the ":" after "A"


In article ,
"Todd Huttenstine"

wrote:

Well its looping through correctly, but then when it

finds
a cell that equals the #N/A error, it hits the

following
line of code...

Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1

I get the error Runtime error 1004 Application defined

or
object defined error.

.

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Loop Problem

Excel returns the Error (xlErrNA, or 2042) in the Value property if the
formula returns #N/A.

You could use:

If cell1.Text = "#N/A" Then

instead.


Todd - you've been posting here long enough to know that you should
include the error message that you get, rather than just saying "an
error".

In article ,
"Todd Huttenstine" wrote:

Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1 = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1
Else
End If
Next

I keep getting an error with the above code. It is not
seeing the #N/A error correctly. There are formulas all
in range O2:O100. How would I make this work?



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Loop Problem

Todd Huttenstine wrote:
Dim rng As Range
Dim cell1 As Object
Set rng = Sheets("Converted Data").Range("O2:O100")
For Each cell1 In rng
If cell1 = "#N/A" Then
Sheets("Mismatches").Range("A:" & Sheets
("Mismatches").Range("H2").Value) = cell1
Else
End If
Next

I keep getting an error with the above code. It is not
seeing the #N/A error correctly. There are formulas all
in range O2:O100. How would I make this work?

Thank you

Todd Huttenstine


Another option is to use the ISNA() worksheet function

If Application.IsNa(cell1.Value) Then

--
Regards,

Juan Pablo González


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
do while loop problem April Excel Discussion (Misc queries) 4 October 18th 09 07:51 PM
For...Each Loop Problem SuperJas Excel Programming 4 April 2nd 04 05:01 AM
Problem with Loop Mike Excel Programming 7 February 26th 04 09:12 PM
For..Next loop problem Dwaine Horton Excel Programming 1 February 18th 04 12:12 AM
loop problem joao Excel Programming 4 November 6th 03 02:01 PM


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