+ Reply to Thread
Results 1 to 6 of 6

Code to delete columns based on variable

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    sydney
    MS-Off Ver
    Excel 2010
    Posts
    9

    Code to delete columns based on variable

    Hi All

    Can anyone think of a code where it would delete whole columns based on the column name which is in the inputs tab.
    I need to be able to 1. Change the column order freely. 2. Change the inputs. 3. The code to find the column based on the inputs.
    Attached is a sample report.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,904

    Re: Code to delete columns based on variable

    This should do it for you, but you will have to spell each of the delete column in Inputs exactly the same as the headers in Normalised data sheet. No abbreviations.

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to delete columns based on variable

    try this macro:-

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-10-2013
    Location
    sydney
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Code to delete columns based on variable

    Thanks Alan, this is exactly what i need appreciate your quick response!

  5. #5
    Registered User
    Join Date
    07-10-2013
    Location
    sydney
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Code to delete columns based on variable

    Thanks mehmetcik for your code too

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,904

    Re: Code to delete columns based on variable

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks for the rep

+ 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. sorting columns based on row criteria, with variable number of columns
    By bardobhb in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-02-2014, 04:02 PM
  2. Delete columns & Row based on criteria VBA code needed
    By Gary B in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-28-2014, 02:59 PM
  3. Delete Range based on cell value with variable row - Should be simple
    By RichTea88 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2014, 06:34 AM
  4. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 AM
  5. 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

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