+ Reply to Thread
Results 1 to 17 of 17

If characters are specficially this then change current cell

  1. #1
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Unhappy If characters are specficially this then change current cell

    Hello!

    I need to have a rather long if statement that sorts out through the characters in a cell and if the characters are present, then it changes the cell that the formula is in:

    Example:

    LV.CH.1.1 If that cell has CH in that spot then this cell is Furniture

    LV.CH.134.1.Grey If that cell has CH in that spot then this cell is Furniture

    then after a while of cells it would look like:

    LV.CH.1.11 IF that cell has CH or TB or .. or .. in that spot then this cell is Furniture
    LV.CH.1.5 IF that cell has CH or TB or .. or .. in that spot then this cell is Furniture
    LV.CH.50.1 IF that cell has CH or TB or .. or .. in that spot then this cell is Furniture
    LV.TB.51.1 IF that cell has CH or TB or .. or .. in that spot then this cell is Furniture

    etc like that

    I hope it makes sense. I'm having trouble with the locating of the CH, TB, CD, etc without the rest of the cell like, specifically 3 characters in and then look at the 2 and skip the rest.

    THANK YOU

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: If characters are specficially this then change current cell

    Unless I am missing something all you need is the mid function.

    If your data is in A1 then this formula in B1

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by mehmetcik; 11-15-2016 at 07:23 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    THANK YOU!

    I was getting very confused. This is amazing.

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,911

    Re: If characters are specficially this then change current cell

    Or try this ...

    =IF(OR(MID(A1,4,2)={"CH","TB"}),"Furniture","")

  5. #5
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    Quote Originally Posted by mehmetcik View Post
    Unless I am missing something all you need is the mid function.

    If your data is in A1 then this formula in B1

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This is what I have adapted it to:

    Please Login or Register  to view this content.
    and it seems to be backwards/not working properly? Any suggestions?

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: If characters are specficially this then change current cell

    In your sample you used two characters for code.

    Here you are using 3 in some instances and 4 in one instance.

    It is still possible but would be easier with a user defined function.

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    This code will achieve the same result using the formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    To install the code, click on the developer tab in excel
    Click on Visual Basic
    Click on insert and then Module

    Paste this code and close visual basic.


    Hopefully you can see that this solution would be a lot easier to maintain.
    Last edited by mehmetcik; 11-15-2016 at 09:37 PM.

  7. #7
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    Quote Originally Posted by mehmetcik View Post
    In your sample you used two characters for code.

    Here you are using 3
    Ahh, I see I need to change my ThB/ThP/Etc to 2 character abbreviations.
    Okay, I can probably do that. However, Let's say that some of these 3
    character ones are crucial is there a work away around that?

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: If characters are specficially this then change current cell

    I have provided two workable solutions for you in my last post.

  9. #9
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    Okay, I got the longer piece working, but can't get the module working. Which isn't the end of the world because I can just use the if statements.

  10. #10
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    Quote Originally Posted by mehmetcik View Post
    I have provided two workable solutions for you in my last post.
    When my characters are DN.TLa.1.1, it displaying LightingFlooring. Probably because TL is flooring and TLa is lighting, any suggestions?

  11. #11
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: If characters are specficially this then change current cell

    Move the If statement for lighting before the statement for flooring

    I will insert the code into a sample spreadsheet for you. That is the way ahead.
    Attached Files Attached Files
    Last edited by mehmetcik; 11-16-2016 at 02:27 PM.

  12. #12
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    Quote Originally Posted by mehmetcik View Post
    Move the If statement for lighting before the statement for flooring

    I will insert the code into a sample spreadsheet for you. That is the way ahead.
    Okay, this is working awesomely, but now I have another set of cells that have characters that look like this: DN.B.CH.1.1 is there a way we could modify the code above to make it work with the extra characters in there?

    Thank you!!

  13. #13
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: If characters are specficially this then change current cell

    I need more details.

  14. #14
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    Quote Originally Posted by mehmetcik View Post
    I need more details.
    Before it looked like;
    LV.CH.1.1
    LV.Tla.1.1

    Now it looks like;
    LV.D.CH.1.1
    LV.C.Tla.1.1

    with the extra character before the important CH.

    Still wanting it to do the exact same thing with the exact same output, but now there are 2 extra characters in the cell

  15. #15
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: If characters are specficially this then change current cell

    Ok are you using formulas or the user defined function?

    Revised formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Revised UDF:

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 11-16-2016 at 08:34 PM.

  16. #16
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    The function seems to be working! Thank you so much! Will mark as solved until I do some further testing, thank you.

  17. #17
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: If characters are specficially this then change current cell

    Quote Originally Posted by mehmetcik View Post
    Ok are you using formulas or the user defined function?

    Revised formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Revised UDF:

    Please Login or Register  to view this content.
    Once I saved it all went away and reset the function. Is there a specific format I should be saving in ?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Change background of all characters in cell except last 4
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2016, 01:24 PM
  2. Trying to change the value of a cell based on its current value
    By ma1986 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2015, 06:42 AM
  3. Change the content of a cell based on change the current date
    By aimanraya in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-14-2014, 07:07 AM
  4. [SOLVED] Add characters to number in current cell(s)
    By maw230 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-02-2014, 02:46 PM
  5. [SOLVED] Change name of current sheet using cell value
    By Grimace in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2013, 09:02 PM
  6. Change CURRENT CELL
    By bobptex in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-01-2012, 06:15 PM
  7. Change Cell Color if in current Month
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 09-06-2005, 12:05 PM

Tags for this Thread

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