Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default loop and fine & replace

I need to loop through an entire range ("A1:X16"), looking at each cell to
see if it has #N/A in it. If N/A is not found I need to close the workbook.
If it is found, I need to replace it with "" save and close the workbook.
The reason I'm looping first rather than just find and replacing is because
when the data isn't found, an excel message box comes up saying no data could
be found and I want to avoid this message box. Any ideas on how to do this?
I'm using Visual Studio rather than VBA, they are very similar but a few
things are different, but any ideas will be greatly appreciated! Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default loop and fine & replace

VBA, you will have to adapt

fFound = False
For Each cell in Range("A1:X16")
If Application.ISNA(cell.value) then
cellValue = ""
fFound= True
EndIf
Next cell

If fFound Then
Activeworkbook.Save
Endif

Activeworkbook.Close

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"NewToVB" wrote in message
...
I need to loop through an entire range ("A1:X16"), looking at each cell
to
see if it has #N/A in it. If N/A is not found I need to close the
workbook.
If it is found, I need to replace it with "" save and close the workbook.
The reason I'm looping first rather than just find and replacing is
because
when the data isn't found, an excel message box comes up saying no data
could
be found and I want to avoid this message box. Any ideas on how to do
this?
I'm using Visual Studio rather than VBA, they are very similar but a few
things are different, but any ideas will be greatly appreciated! Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default loop and fine & replace

Thank you!

"NewToVB" wrote:

I need to loop through an entire range ("A1:X16"), looking at each cell to
see if it has #N/A in it. If N/A is not found I need to close the workbook.
If it is found, I need to replace it with "" save and close the workbook.
The reason I'm looping first rather than just find and replacing is because
when the data isn't found, an excel message box comes up saying no data could
be found and I want to avoid this message box. Any ideas on how to do this?
I'm using Visual Studio rather than VBA, they are very similar but a few
things are different, but any ideas will be greatly appreciated! Thanks!

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
Macro fine Run fine from Select but not from KB Shortcut? [email protected] Excel Discussion (Misc queries) 8 August 31st 06 02:06 AM
Msg Box on each Loop to Replace text Ricky Pang Excel Programming 10 May 10th 06 11:47 PM
Loop in my macro doesn't seem to be running; however, it compiles fine... Goobies[_3_] Excel Programming 6 February 2nd 06 01:00 AM
Replace using Do loop Dave B[_9_] Excel Programming 1 November 29th 05 07:35 PM
Replace Loop Darrell[_4_] Excel Programming 1 November 21st 03 04:49 PM


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