View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Excel VBA - Type mismatch during While

Code worked fine for me as I changed it.

While ActiveCell.Text < "#N/A"
ActiveCell.Offset(0, -3).Select
ActiveCell.Copy
ActiveCell.Offset(0, 4).Select
ActiveCell.PasteSpecial
ActiveCell.Offset(1, -1).Select
Wend

Apparently there is something else wrong with your worksheet.

--
Regards,
Tom Ogilvy



"sub_pop " wrote in message
...
Thanks Tom,
Unfortunately, even when the result - #N/A, condition is met and the
copy and paste take place. Is there an ActiveCell.Result?

Thanks,
Marc


Tom Ogilvy wrote

*While ActiveCell.Text < "#N/A"
ActiveCell.Offset(0, -3).Select
ActiveCell.Copy
ActiveCell.Offset(0, 4).Select
ActiveCell.PasteSpecial
ActiveCell.Offset(1, -1).Select
Wend

--
Regards,
Tom Ogilvy

"sub_pop " wrote in message
...
On a worksheet with 4 columns and ~300 rows, where the 4th column is

the
same formula in each row, returning a value for the first ~10-20, I
want to paste the contents of the 1st column into the 5th column of

the
same row, so long as the result of the formula in column 4 is not
"#N/A"

What I have looks like this:
While ActiveCell < "#N/A"
ActiveCell.Offset(0, -3).Select
ActiveCell.Copy
ActiveCell.Offset(0, 4).Select
ActiveCell.PasteSpecial
ActiveCell.Offset(1, -1).Select
Wend

This works well for adding the 5th column, but errors out as a Type
Mismatch when it reaches the first row where the result in column 4

is
#N/A. Any help is greatly appreciated


---
Message posted from http://www.ExcelForum.com/
*



---
Message posted from http://www.ExcelForum.com/
[/i]