Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Macro for removing error values in cells.

Hi,

I have a set of data in column H and most of the cells has the error
value "#N/A".
I want to replace the error value from "#N/A" to "-"(Dash).
Following is the code but I am getting a error (Type Mismatch) while
running the code.

Range("H5").Select

Do Until ActiveCell.Value = ""
If ActiveCell.Value = "#N/A" Then
ActiveCell.Value = "-"
Selection.Offset(1, 0).Select
End If
Selection.Offset(1, 0).Select
Loop

Can someone suggest me the code which can replace the error values.

Regards
Heera Chavan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro for removing error values in cells.

You can use
if activecell.text = "#N/A" then



Heera wrote:

Hi,

I have a set of data in column H and most of the cells has the error
value "#N/A".
I want to replace the error value from "#N/A" to "-"(Dash).
Following is the code but I am getting a error (Type Mismatch) while
running the code.

Range("H5").Select

Do Until ActiveCell.Value = ""
If ActiveCell.Value = "#N/A" Then
ActiveCell.Value = "-"
Selection.Offset(1, 0).Select
End If
Selection.Offset(1, 0).Select
Loop

Can someone suggest me the code which can replace the error values.

Regards
Heera Chavan


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Macro for removing error values in cells.

First you establish your range something like this:

iLastrow = Range("H65536").End(xlUp).Row
Set Rng = Range("H5:H" & iLastrow)
Then Establish the loop and activate cell:
For Each Rng In Rng

Rng.Activate

If IsError(ActiveCell.Value) Then
errval = ActiveCell.Value
Select Case errval
Case CVErr(xlErrDiv0)
MsgBox "#DIV/0! error"
Case CVErr(xlErrNA)
MsgBox "#N/A error"
Case CVErr(xlErrName)
MsgBox "#NAME? error"
Case CVErr(xlErrNull)
MsgBox "#NULL! error"
Case CVErr(xlErrNum)
MsgBox "#NUM! error"
Case CVErr(xlErrRef)
MsgBox "#REF! error"
Case CVErr(xlErrValue)
MsgBox "#VALUE! error"
End Select
End If
Next
Replace the MsgBox for:
ActiveCell.Value = "-"
or for anythingelse you may want
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Heera" wrote:

Hi,

I have a set of data in column H and most of the cells has the error
value "#N/A".
I want to replace the error value from "#N/A" to "-"(Dash).
Following is the code but I am getting a error (Type Mismatch) while
running the code.

Range("H5").Select

Do Until ActiveCell.Value = ""
If ActiveCell.Value = "#N/A" Then
ActiveCell.Value = "-"
Selection.Offset(1, 0).Select
End If
Selection.Offset(1, 0).Select
Loop

Can someone suggest me the code which can replace the error values.

Regards
Heera Chavan

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
Error with copying values in cells SabrinaB Excel Discussion (Misc queries) 2 August 21st 09 04:19 PM
cells without values causing error message karen Excel Discussion (Misc queries) 6 January 11th 08 06:39 PM
Hiding error values in cells brisen09 Excel Worksheet Functions 1 August 16th 06 09:20 AM
Macro to replace error values Shamik Excel Programming 2 June 12th 06 09:09 PM
Removing already used values Jim Brass Excel Programming 0 November 10th 04 02:04 AM


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