+ Reply to Thread
Results 1 to 16 of 16

Searching a cell value for a Character

  1. #1
    Registered User
    Join Date
    01-15-2008
    Posts
    66

    Question Searching a cell value for a Character

    Hi all,
    Thanks for all the help so far. I have a final challenge for my program.

    I want to test a cell for the type of value as 678/256 or 345/872/098/987 etc. The common character in each would be the "/". First, I need to check the cell for this, then take the first number and compare it to an integer(if it is <> , or = to). I hope I am clear with my situation. All help is welcomed

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    You mean something like:

    Please Login or Register  to view this content.
    where A1 contains original code and B1 contains number to compare to.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    01-15-2008
    Posts
    66
    Thanks,
    I can play with those statments. what I am looking for is something like:

    If cells(i,"G").value contain "/" then flag=1
    If flag=1 then retrieve "first number" of value as integer

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    If you were looking for a VBA solution, you should've posted in the Programming forum...

    We'll see if someone with VBA skills will join and add a suggestion.

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon dsexpress

    For clarification - are you wanting to extract each number from the string in a cell?
    What are you hoping to compare them to?

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  6. #6
    Registered User
    Join Date
    01-15-2008
    Posts
    66
    I just want to get the first number: eg

    289/345/896 result would be integer 289
    23/45 " " integer 23
    684/234/123/456 ' '' integer 684


    I am then comparing this value to a sum of numbers in a collection of cells

    Thanks

  7. #7
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi dsexpress

    This code will do what you want, but in the absence of guidance from yourself, it will take its value from A1, and subtract from that the sum of values in range B1:B10, and then display the result in a MsgBox :
    Please Login or Register  to view this content.
    HTH

    DominicB

  8. #8
    Registered User
    Join Date
    01-15-2008
    Posts
    66
    Yes, thanks
    That helps with the extraction. I just need to test the cell for contents of "/". I am going to assume the find function?

  9. #9
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi dsexpress

    Quote Originally Posted by dsexpress
    I just need to test the cell for contents of "/". I am going to assume the find function?
    I'm not sure what you mean. Do you want to test first whether the cell contains a "/"? If so what do you want to do if a "/" isn't found?

    If I've got it totally wrong and am barking up the wrong tree, explain to me exactly what you mean.

    DominicB

  10. #10
    Registered User
    Join Date
    01-15-2008
    Posts
    66
    I appreciate your patience. Ill try by example:

    For i = 1 to 17
    If cells(i,"G").value = ( 234/45/67 (value with "/") ) then flag=1
    a= a+cells(i,"K").value
    next i

    Case flag=1
    if a<>234 then color cells(i,"G").value (First Number only) red

    I hope thats better

  11. #11
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi dsexpress
    Quote Originally Posted by dsexpress
    I appreciate your patience. Ill try by example
    OK, I think I see where you're trying to go now. See if this meets your needs :
    Please Login or Register  to view this content.
    HTH

    DominicB

  12. #12
    Registered User
    Join Date
    01-15-2008
    Posts
    66
    wouldn't Ex be a string? If so, do I need to convert it?

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    This seems to follow the logic of your pseudo-code:
    Please Login or Register  to view this content.
    Last edited by shg; 04-28-2008 at 03:22 PM.

  14. #14
    Registered User
    Join Date
    01-15-2008
    Posts
    66
    Thanks all,
    Feels great to have this done after ####### hrs.....

  15. #15
    Registered User
    Join Date
    01-15-2008
    Posts
    66
    How do I lable this thread closed?

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    No need .

+ 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