+ Reply to Thread
Results 1 to 10 of 10

Search Entire Workbook for Certain Text, and blank out cells

  1. #1
    Registered User
    Join Date
    08-23-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    14

    Search Entire Workbook for Certain Text, and blank out cells

    I have a situation where I have a excel file that contains info that only certain people should be able to see All the Data. I decided to create a VBA script that when the file is saved, It saves Two copies of this file, one for un-privileged users to see certain data, and the original for privileged users to see everything.

    After the File was saved for the Unprivileged, I need to scan through it and blank out the cells that they should not see.

    What I have so far is this:
    Please Login or Register  to view this content.

    So, Im not sure if I am starting this in the correct way, but for what i have, I am stuck now on how to access a cell and read its value based on the row and column index.

    Can someone give me a hand?

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Search Entire Workbook for Certain Text, and blank out cells

    how about:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-18-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Search Entire Workbook for Certain Text, and blank out cells

    This one will change all the 9s in any of the sheets to "Redacted"

    I don't know how many values you want to hide, but if you have a lot you could make an array and put another loop around the If statement:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-23-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Search Entire Workbook for Certain Text, and blank out cells

    Thank you both for your super fast reply, but I have to give my hand to NickyC for small and simple code. I should have stated before, but I need to blank a cell that has the cell formatted as money. My first look at the spreadsheet I thought they had placed a $ with the value, but it seems the cell contents itself is just numeric but its formatted as money. Would it be easy to search and see what the cell formatting is and blank that if its currency?

    I tried "If Replace(cc.NumberFormat, "$", "") <> cc.NumberFormat Then" but some of the cells are formatted with the Date, which has a $ in its formatting: "[$-409]mmm-yy;@", so this also removes the Dated Cells, lol.

    Any Ideas?
    Last edited by changedsoul; 08-24-2012 at 07:09 PM.

  5. #5
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Search Entire Workbook for Certain Text, and blank out cells

    Hi
    try this

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-23-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Search Entire Workbook for Certain Text, and blank out cells

    Thanks, that worked perfectly.

    On a side note, Is it possible to sort an entire sheet by date in a given column, but only if the cell is not a certain color?
    I know its possible by doing it manually, but if its done by script, will it have problems?

  7. #7
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Search Entire Workbook for Certain Text, and blank out cells

    Not sure I understand what you're trying to do - if you're sorting the entire column, where do the coloured cells go?

  8. #8
    Registered User
    Join Date
    08-23-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Search Entire Workbook for Certain Text, and blank out cells

    Well I implemented what you suggested for removing the dollar amounts and it works great. I showed it to the Office worker that will be using it, and they asked me if it were possible to sort a certain column based on date. They do it manually as of now.

    Its basically a shipping log. They color each Row Yellow for shipped items, and then other colors based on not shipped yet, late, etc.
    What they do now is highlight all cells that are not yellow, then select sort by date from the Data menu so they can see what needs to be shipped and when.
    So I guess i would need to know at what Row the Yellow cells stop, and then select everything else and then sort by date based on one Column.
    Or if the Yello cells are scattered, I guess I would have to group all the yellow cells together, and then find the Row they end at, and then select everthing else.

    I dont know if I explained it clear enough, do you understand what I am trying to ask?

  9. #9
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Search Entire Workbook for Certain Text, and blank out cells

    Hi
    you could do a sort on cell colour, then on value
    this is a menu option under the "sort" tab

  10. #10
    Registered User
    Join Date
    08-23-2012
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Search Entire Workbook for Certain Text, and blank out cells

    I was thinking about doing something like this by macro, but I ran into a problem.
    The first three rows and column headers and merged cells.
    When trying to sort by color the entire worksheet I am given an error about merged cells.
    So is it possible to:
    1: Select The entire worksheet, without the first three Rows selected? Then sort this by color.
    2: Locate the beginning and ending cells of the sorted color so i can then select these, and sort by date?

    I tried using the Macro recorder to see some of the commands it issues, but its always using Cell address, and for what I am trying to do, I will not know what cells are colored or not, etc

+ 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