ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determining A Cell If it contain A string value (https://www.excelbanter.com/excel-programming/338434-determining-cell-if-contain-string-value.html)

Rob

Determining A Cell If it contain A string value
 
I've always have trouble with this one could someone help?
I can determine if a cell has a numeric value but not a string value.
Sometimes I can get it to work but for some reason it's not very reliable?
As a result need a more definate code.
I have attached the macro, it is range 02 that is giving me grieve

If Range(range01) 0 And Range(range02) < 0 Then

It was as below which worked sometimes works

If Range("B1") = "" And Range("C1") < "" Then



Doug[_15_]

Determining A Cell If it contain A string value
 
=ISNUMBER(xx) will return true if location xx has a numeric value and
false other wise.

Doug


Brtw

Determining A Cell If it contain A string value
 
I recently was looking for something like this myself. Below is what I
used to solve my problem.

If InStr(ActiveCell, SearchItem) 0 Then

' where SearchItem was a string value that I have as a user input

In the definition of InStr, the first notation is said to be [Start].
The problem I ran into was I could only get it to search one cell, and
then force it to .Offset right or down one to suit my need.

The way I understood it was that if InStr finds what its looking for it
returns a number value higher than 0, thus ' 0 ' would be necessary.


Tom Ogilvy

Determining A Cell If it contain A string value
 
Use the text property of the range and it will always be a string.

Beyond that, you would need a clearer explanation of what you problem is.

--
Regards,
Tom Ogilvy

"Rob" wrote in message
...
I've always have trouble with this one could someone help?
I can determine if a cell has a numeric value but not a string value.
Sometimes I can get it to work but for some reason it's not very reliable?
As a result need a more definate code.
I have attached the macro, it is range 02 that is giving me grieve

If Range(range01) 0 And Range(range02) < 0 Then

It was as below which worked sometimes works

If Range("B1") = "" And Range("C1") < "" Then





Rob

Determining A Cell If it contain A string value
 
Thanks for prompt reply, I'm not quite sure what you mean by text properties?
Is that Cell format? as I'm trying to avoid listing of possible variables

"Tom Ogilvy" wrote:

Use the text property of the range and it will always be a string.

Beyond that, you would need a clearer explanation of what you problem is.

--
Regards,
Tom Ogilvy

"Rob" wrote in message
...
I've always have trouble with this one could someone help?
I can determine if a cell has a numeric value but not a string value.
Sometimes I can get it to work but for some reason it's not very reliable?
As a result need a more definate code.
I have attached the macro, it is range 02 that is giving me grieve

If Range(range01) 0 And Range(range02) < 0 Then

It was as below which worked sometimes works

If Range("B1") = "" And Range("C1") < "" Then






Rob

Determining A Cell If it contain A string value
 
Thanks for prompt reply, it's not the number I'm after, is ther a code for a
string Value?

"Doug" wrote:

=ISNUMBER(xx) will return true if location xx has a numeric value and
false other wise.

Doug



Rob

Determining A Cell If it contain A string value
 
Thanks for prompt reply, I think I understand, will try it on Monday, as I'm
finishing for the day. Have a good weekend.

"Brtw" wrote:

I recently was looking for something like this myself. Below is what I
used to solve my problem.

If InStr(ActiveCell, SearchItem) 0 Then

' where SearchItem was a string value that I have as a user input

In the definition of InStr, the first notation is said to be [Start].
The problem I ran into was I could only get it to search one cell, and
then force it to .Offset right or down one to suit my need.

The way I understood it was that if InStr finds what its looking for it
returns a number value higher than 0, thus ' 0 ' would be necessary.



Tom Ogilvy

Determining A Cell If it contain A string value
 
The text property or a single cell range returns the displayed value of the
cell. It is always a string. If the cell contains zero, then cell.Text
would be "0"

So instead of using cell = 0, (which is really cell.value = 0), you could
use cell.Text = "0"

My answer was just a guess, however, because it really isn't clear what you
are asking. (note the variety of answers you received)

--
Regards,
Tom Ogilvy

"Rob" wrote in message
...
Thanks for prompt reply, I'm not quite sure what you mean by text

properties?
Is that Cell format? as I'm trying to avoid listing of possible variables

"Tom Ogilvy" wrote:

Use the text property of the range and it will always be a string.

Beyond that, you would need a clearer explanation of what you problem

is.

--
Regards,
Tom Ogilvy

"Rob" wrote in message
...
I've always have trouble with this one could someone help?
I can determine if a cell has a numeric value but not a string value.
Sometimes I can get it to work but for some reason it's not very

reliable?
As a result need a more definate code.
I have attached the macro, it is range 02 that is giving me grieve

If Range(range01) 0 And Range(range02) < 0 Then

It was as below which worked sometimes works

If Range("B1") = "" And Range("C1") < "" Then









All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com