+ Reply to Thread
Results 1 to 13 of 13

Trying to make macro hide row if cells contain specific text

  1. #1
    Registered User
    Join Date
    01-10-2012
    Location
    Southampton, England
    MS-Off Ver
    Professional 2010
    Posts
    4

    Trying to make macro hide row if cells contain specific text

    Hi,

    I am pretty new to using VBA and macros in excel. I currently have a large spreadsheet which is used for testing. I have multiple worksheets and on each sheet, there are many rows each containing test procedures and outcomes.

    What I'm trying to do:
    Some of the tests in each sheet only apply to certain products. In each row the test is detailed, the outcome can be recorded, and the products that the test applies to are listed e.g.

    Column 1 - Test Procedure
    Column 2 - Outcome
    Column 3 - ProductA, ProductC etc

    I need the macro to look at Column 3 and search for text relating to each product as I specify elsewhere in the sheet. I will create a button on the first sheet named as the product I want to select. This would then go through each row on each seet in the work book and hide any rows where the Product name is NOT listed. Here is what I have so far:

    Please Login or Register  to view this content.
    At the moment this code works if the ONLY text in the cells is "ProductA". This doesnt work if multiple products are listed in the cell e.g. "ProductA, ProductB".
    I would also like the macro to ignore any blank cells.

    I thought it would be easy but with my limited knowledge I am completely stuck.

    Any help would be much appreciated!
    Last edited by Chris0204; 01-13-2012 at 04:16 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Newbie requires Macro help please!

    Welcome to the Forum.

    Before the moderators give you an infraction (if they do, others cant reply to you till you correct the mistakes), its better you correct the following -

    - Change your title to something that explains your issue much more clearly. Avoid using help, urgent, etc.
    - Add code tags to your code (See forum rules for instructions).
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Newbie requires Macro help please!

    Post duplicated hence removed.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Newbie requires Macro help please!

    Arlette, how have you removed it?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    01-10-2012
    Location
    Southampton, England
    MS-Off Ver
    Professional 2010
    Posts
    4

    Re: Trying to make macro hide row if cells contain specific text

    Post edited for forum compliance. Sorry! :D

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Trying to make macro hide row if cells contain specific text

    It will be difficult to work with multiple products in one cell. Why is this necessary? If you had one product per cell then you could simply use AutoFilter
    Last edited by royUK; 01-10-2012 at 09:27 AM.

  7. #7
    Registered User
    Join Date
    01-10-2012
    Location
    Southampton, England
    MS-Off Ver
    Professional 2010
    Posts
    4

    Re: Trying to make macro hide row if cells contain specific text

    Quote Originally Posted by royUK View Post
    It will be difficult to work with multiple produycts in one cell. Why is this necessary? If you had one product per cell then you could simply use AutoFilter
    We have a range of 7 products. Some tests will apply to say 5 of them whereas other tests may only apply to 1 of them. The tests are broken down in to categories which are on each separate sheet. We want the spreadsheet to cover all of our products so on the first page you select which product you are testing and then run through the spreadsheet, with all tests that aren't applicable to that product being hidden.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Trying to make macro hide row if cells contain specific text

    To attach a file to your post, you need to be using the main 'New Post' or 'New Thread' page and not 'Quick Reply'.
    To use the main 'New Post' page, click the 'Post Reply' button in the relevant thread.

    On this page, below the message box, you will find a button labelled 'Manage Attachments'.
    Clicking this button will open a new window for uploading attachments.

    You can upload an attachment either from your computer or from another URL by using the appropriate box on this page.
    Alternatively you can click the Attachment Icon to open this page.

    To upload a file from your computer, click the 'Browse' button and locate the file.

    To upload a file from another URL, enter the full URL for the file in the second box on this page.
    Once you have completed one of the boxes, click 'Upload'.

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Trying to make macro hide row if cells contain specific text

    @Roy - I didnt remove the post, it is still there, i just removed the duplicated contents. It got saved twice.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Trying to make macro hide row if cells contain specific text

    I thought that you had deleted a post

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Trying to make macro hide row if cells contain specific text

    I dont have rights to delete it.

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Trying to make macro hide row if cells contain specific text

    That's what I was checking, deleting posts is restricted to moderators but may have been changed in the upgrade

  13. #13
    Registered User
    Join Date
    01-10-2012
    Location
    Southampton, England
    MS-Off Ver
    Professional 2010
    Posts
    4

    Re: Trying to make macro hide row if cells contain specific text

    Ok I did a bit more hunting on other websites and found my solution.

    Changed
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    It now works perfectly.

+ 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