+ Reply to Thread
Results 1 to 10 of 10

Macro - Place number & color when find word "inactieve"

  1. #1
    Registered User
    Join Date
    09-03-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    45

    Macro - Place number & color when find word "inactieve"

    Hello,

    I need a small piece of code that search for the word "inactieve".
    When he finds that, he has to make that whole row color 35, and place the number "1" in that row in Column (A)
    Then he has to go 2 rows up, and make that row also color 35. and also place the number "1" in that row in Column (A).

    This piece of code needs to work in a module, so that i can make a macro within a central .xls file and always open that .xls when i need to use the macro on other .xls files.
    I know there are easier options for using macro's on other files, like .xla but here at work that isn't an option.

    I hope someone can help me.

    (I also can't give an example, because it's all stuff from work (private).

    - Jessy

    If anything is unclear, just ask me for more information!

    (Sorry for my poor english)

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro - Place number & color when find word "inactieve"

    you can attach a sample file with no real content
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    09-03-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Macro - Place number & color when find word "inactieve"

    Example.



    - Jessy
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    02-24-2011
    Location
    Belfast, N. Ireland
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Macro - Place number & color when find word "inactieve"

    Jessy,

    In the example posted there is a space between each line of data and the data starts on row 3, is this always the same in the real data?

    Also, colour 35 is very dark and nearly unreadable, the yellow you have used in the example is colour 65535, is the yellow the one you want?

    Mowgli

  5. #5
    Registered User
    Join Date
    09-03-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Macro - Place number & color when find word "inactieve"

    Mowgli,

    The empty space between each line of data is normally filled with data too, but that's not important.
    It is always 1 line between the data.
    It doesn't start on row 3 in the real data.
    The macro just have to find the word "inactieve" then make that line yellow and then 2 rows up, and make that line also yellow.
    And place "1" in column (A) of the yellow lines

  6. #6
    Forum Contributor
    Join Date
    02-24-2011
    Location
    Belfast, N. Ireland
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Macro - Place number & color when find word "inactieve"

    Attached is an attempt, let me know if it is what you are after or if you need it changed.

    I have assumed that the data starts on row 3 but highlighted the 2 lines of code where this can be changed to suit. Also I used the yellow in your example to colour the rows but again highlighted in the code where this can be changed. The last assumption I made (I know, I make a lot of assumptions), is that the data in your actual worksheet is in a large table which does not have a space between each line, if this is wrong let me know and I can modify the code slightly to make it work.

    Mowgli

    Werkmap1 RevA.xlsm
    Attached Files Attached Files
    Last edited by Mowgli; 09-26-2012 at 06:47 AM. Reason: Modified Attachment

  7. #7
    Registered User
    Join Date
    09-03-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Macro - Place number & color when find word "inactieve"

    It just have to look through the whole sheet, it dont have to start at row 3 especially.
    In the real document, there are many blocks of data.

    Just when he sees "inactieve", he has to make that line yellow, and 2 lines up -> also yellow.
    When he made that line yellow, that line also needs "1" in column (A)

    The document you sent me with the code, is nearly what i want!

    Hope you can change it a little bit.

  8. #8
    Registered User
    Join Date
    09-03-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Macro - Place number & color when find word "inactieve"

    In the real document, it is only possible that the word "inactieve" is in Column (B).
    But, it doesn't only contain "inactieve" in it. It's a row filled with "inactieve blablablablabla".
    So, he has to look if there is in (B) a line starting with "inactieve", if so; make line yellow, 2 rows up, also yellow and the yellow rows -> "1" in (A) of that row

    - Jessy

  9. #9
    Forum Contributor
    Join Date
    02-24-2011
    Location
    Belfast, N. Ireland
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Macro - Place number & color when find word "inactieve"

    Ok, think I better understand what you are after. Have changed the code to search all of Column B for any time the word inactieve is included within a cell and it will then carry out the formatting required.Werkmap1 RevB.xlsm

  10. #10
    Registered User
    Join Date
    09-03-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Macro - Place number & color when find word "inactieve"

    Yes!
    I will try that tomorrow on my own data.

    Thanks for now!

    ( +Rep for you!)

+ 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