+ Reply to Thread
Results 1 to 5 of 5

Need code to delete column if cell contains certain value

  1. #1
    Registered User
    Join Date
    05-19-2014
    Posts
    9

    Post Need code to delete column if cell contains certain value

    I am attaching a sample file for reference.

    On the sheet titled Price List, in row 1, I have an =IFERROR(HLOOKUP( formula to show what I need. The Data Pull sheet can be updated using a third party software, and retailers can be added or deleted. The purpose is that if a retailer is deleted from the Data Pull sheet, it will automatically be removed from the list on the Price List sheet, rather than just showing a bunch of N/A's in every cell. Then if it is re-added in the future, it will repopulate on the Price List sheet.

    The formula I have in row 1 is my manual way of showing whether or not the retailer was deleted. If it contains EXCLUDE, you can go in and manually delete the column. However, I would rather have a macro do this.

    Please let me know if you need more clarification, and thanks for the help in advance!

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Need code to delete column if cell contains certain value

    Hi there,

    Try this on the sheet in question:

    Please Login or Register  to view this content.
    As the delete cannot be undone, I'd recommend you initially try it on a sample of your data in case the results are not as expected.

    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    05-19-2014
    Posts
    9

    Re: Need code to delete column if cell contains certain value

    That code worked for the deletion - but I cannot reverse that so it would readd the column if it were reincluded in the future. would that be an entirely new set of code, or can you modify that code you just provided?

    So if one week, Target was removed from the Data Pull worksheet - that code would work to remove target from the Price List worksheet
    however, if the week after, Target was re-added to the Data Pull worksheet, that code did not work to re-add Target to the Price List worksheet.

    Would you know how to solve that problem?

  4. #4
    Registered User
    Join Date
    05-19-2014
    Posts
    9

    Re: Need code to delete column if cell contains certain value

    Actually - I do not need to repopulate cells.
    That code worked great.

    THANKS!!!!

  5. #5
    Registered User
    Join Date
    05-19-2014
    Posts
    9

    Re: Need code to delete column if cell contains certain value

    This code no longer works in the file. When I first was using it it ran exactly how I wanted it to. Now it does nothing.

    Would changing the file name have anything to do with that? Tab names? I have no idea what is wrong, I did not change the code, or the layout of the sheet.

    Any help would be great!

+ 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. Macro code to delete entire row if cell in column A is equal to a value
    By mm671750 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-07-2014, 02:54 PM
  2. [SOLVED] VB Code to delete column and change column Width
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-28-2014, 06:25 PM
  3. Macro code to delete entire row if the cell in column C = 0
    By glock9mm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-18-2013, 02:50 PM
  4. Code to delete rows based on status code in Column I
    By LemonTwist in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2009, 07:01 PM
  5. VBA Code for deleting rows where cell in column a states "delete row"
    By tnfire in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-20-2009, 06:17 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