+ Reply to Thread
Results 1 to 8 of 8

Determining A Cell If it contain A string value

  1. #1
    Rob
    Guest

    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



  2. #2
    Doug
    Guest

    Re: 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


  3. #3
    Brtw
    Guest

    Re: 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.


  4. #4
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >
    >




  5. #5
    Rob
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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
    > >
    > >

    >
    >
    >


  6. #6
    Rob
    Guest

    Re: 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
    >
    >


  7. #7
    Rob
    Guest

    Re: 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.
    >
    >


  8. #8
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > 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
    > > >
    > > >

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1