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

Why is the macro unable to identify #VALUE! as a string?

I have a macro which inputs functions in to the cells, then cuts and pastes
by values (so that the function results are static). After that I wish to
delete all rows with cells that have #VALUE! (as a string itself) in it, but
it cannot seem to identify it. Below is a test macro to demonstrate. The Cell
A1 should have #VALUE! in it.

Sub test()
If IsEmpty(Cells(1, 1)) Then
MsgBox ("A1 empty")
Else
MsgBox ("A1 not empty")
MsgBox Cells(1, 1).Value
End If
End Sub

Is there any other way I can check whether a cell is containing #VALUE! as a
string?
Thank you.

- Jay -

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA question

Try using IsError on the cell.

--
---
HTH

Bob


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



"jayahn" wrote in message
...
Why is the macro unable to identify #VALUE! as a string?

I have a macro which inputs functions in to the cells, then cuts and
pastes
by values (so that the function results are static). After that I wish to
delete all rows with cells that have #VALUE! (as a string itself) in it,
but
it cannot seem to identify it. Below is a test macro to demonstrate. The
Cell
A1 should have #VALUE! in it.

Sub test()
If IsEmpty(Cells(1, 1)) Then
MsgBox ("A1 empty")
Else
MsgBox ("A1 not empty")
MsgBox Cells(1, 1).Value
End If
End Sub

Is there any other way I can check whether a cell is containing #VALUE! as
a
string?
Thank you.

- Jay -



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default VBA question

hi
intresting concept. sometime what you see in a cell is not what is in the
cell. try this.
Sub test()
If IsEmpty(Cells(1, 1)) Then
MsgBox ("A1 empty")
Else
MsgBox ("A1 not empty")
If IsError(Cells(1, 1)) Then
Rows("1:1").ClearContents
End If
MsgBox Cells(1, 1).Value
End If
End Sub

regards
FSt1

"jayahn" wrote:

Why is the macro unable to identify #VALUE! as a string?

I have a macro which inputs functions in to the cells, then cuts and pastes
by values (so that the function results are static). After that I wish to
delete all rows with cells that have #VALUE! (as a string itself) in it, but
it cannot seem to identify it. Below is a test macro to demonstrate. The Cell
A1 should have #VALUE! in it.

Sub test()
If IsEmpty(Cells(1, 1)) Then
MsgBox ("A1 empty")
Else
MsgBox ("A1 not empty")
MsgBox Cells(1, 1).Value
End If
End Sub

Is there any other way I can check whether a cell is containing #VALUE! as a
string?
Thank you.

- Jay -

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA question

You could check it's .text property.

with worksheets("sheet1")
if isempty(.cells(1,1).value) then
'it's empty
else
if lcase(.cells(1,1).text) = lcase("#VALUE!") then
...



jayahn wrote:

Why is the macro unable to identify #VALUE! as a string?

I have a macro which inputs functions in to the cells, then cuts and pastes
by values (so that the function results are static). After that I wish to
delete all rows with cells that have #VALUE! (as a string itself) in it, but
it cannot seem to identify it. Below is a test macro to demonstrate. The Cell
A1 should have #VALUE! in it.

Sub test()
If IsEmpty(Cells(1, 1)) Then
MsgBox ("A1 empty")
Else
MsgBox ("A1 not empty")
MsgBox Cells(1, 1).Value
End If
End Sub

Is there any other way I can check whether a cell is containing #VALUE! as a
string?
Thank you.

- Jay -


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBA question

Use Cells.Text rather than Cells.Value:

Sub test()
If ActiveCell.Text = "#VALUE!" Then
MsgBox ("found it")
End If
End Sub

--
Gary''s Student - gsnu200764


"jayahn" wrote:

Why is the macro unable to identify #VALUE! as a string?

I have a macro which inputs functions in to the cells, then cuts and pastes
by values (so that the function results are static). After that I wish to
delete all rows with cells that have #VALUE! (as a string itself) in it, but
it cannot seem to identify it. Below is a test macro to demonstrate. The Cell
A1 should have #VALUE! in it.

Sub test()
If IsEmpty(Cells(1, 1)) Then
MsgBox ("A1 empty")
Else
MsgBox ("A1 not empty")
MsgBox Cells(1, 1).Value
End If
End Sub

Is there any other way I can check whether a cell is containing #VALUE! as a
string?
Thank you.

- Jay -



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA question

Great. Thank you all for your responses( and so quick too!).

- Jay -

"jayahn" wrote:

Why is the macro unable to identify #VALUE! as a string?

I have a macro which inputs functions in to the cells, then cuts and pastes
by values (so that the function results are static). After that I wish to
delete all rows with cells that have #VALUE! (as a string itself) in it, but
it cannot seem to identify it. Below is a test macro to demonstrate. The Cell
A1 should have #VALUE! in it.

Sub test()
If IsEmpty(Cells(1, 1)) Then
MsgBox ("A1 empty")
Else
MsgBox ("A1 not empty")
MsgBox Cells(1, 1).Value
End If
End Sub

Is there any other way I can check whether a cell is containing #VALUE! as a
string?
Thank you.

- Jay -

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
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good davegb Excel Programming 1 May 6th 05 06:35 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 27th 05 07:46 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


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