+ Reply to Thread
Results 1 to 3 of 3

Remove columns if certain cell is equal to zero

  1. #1
    Registered User
    Join Date
    06-13-2012
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Remove columns if certain cell is equal to zero

    I was given a highly complicated allocation of effort spreadsheet. I am looking to build a macro that looks within a cell. If that cell is equal to 0.00%, then I need it to delete that column, as well as the two columns prior to it. If it finds a specific cell with a value greater than 0.00%, then it would keep that column as well as the two columns prior to it.

    Attachment macro summary:

    Look in cell E37 (column header = Both). If value is 0.00%, then delete that row as well as column C & D. Repeat the same task in the same row with the column header = Both)

    Essentially, I need the macro to look in cells E37, H37, K37, etc. (wherever the total is with a header = Both) and delete the prior two columns if that value is 0.00%

    I appreciate the help if it this is something that is possible.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    06-13-2012
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Remove columns if certain cell is equal to zero

    Also, if the macro could repeat on the other tabs as well, that would be helpful!

  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: Remove columns if certain cell is equal to zero

    Try this macro on a test file first - You have sum totals in the last column. This shows a REF error once the columns are deleted. Let me know if you want the formulae in that column to be re-input through code. Also ensure that the word "Both" is in row 3 in each sheet of your file.

    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button
    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]

+ 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