+ Reply to Thread
Results 1 to 6 of 6

Delete Columns in Multiple Sheets with repeat macro

  1. #1
    Registered User
    Join Date
    03-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Delete Columns in Multiple Sheets with repeat macro

    Hi all -

    I'm trying to delete multiple columns which are identical across multiple sheets based on an array which is built using user input.

    Through scouring these forums I have gotten this code:

    Please Login or Register  to view this content.
    The code executes the number of times that there is sheets (as exhibited by the msgbox) but the columns are only deleted on the first sheet.

    What do I need to change?

    Thanks in advance for your help.
    Last edited by candie025; 05-16-2014 at 08:59 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Delete Columns in Multiple Sheets with repeat macro

    Hi,

    Welcome to the forum

    Try something like this...
    Please Login or Register  to view this content.
    Regards,
    Rudi

  3. #3
    Registered User
    Join Date
    03-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Delete Columns in Multiple Sheets with repeat macro

    Thanks for the input Rudi but that isn't going to quite work.

    The user input has already been selected. The "SelectArray" is built with a listbox which allows the users to select from a list comprising of all the column headers in the sheet (all are in row 1).

    If a header is selected (say "date" which resides in C1) it is moved from FullArray to SelectArray. Then on each sheet in the workbook I want to compare the headers on the sheet (all of row 1) to the items in SelectArray. If they match then that column (column C) is fully deleted from the sheet and so on and so forth.

    The code I presented executes the deletion perfectly but allows this only on the first sheet where the sheet name is not "start". For some reason subsequent executions of the code to check the first row against the array then delete the matching columns is what is not properly executing.

    Thanks again.

  4. #4
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Delete Columns in Multiple Sheets with repeat macro

    I could be wrong, but try prefixing the SelectArray with Worksheets("Start").
    i'm thinking that you need a reference to the sheet...
    For example:

    Please Login or Register  to view this content.
    OR....

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Delete Columns in Multiple Sheets with repeat macro

    Actually with a little tinkering my husband help me solve it. I had to command the rows on the worksheet.

    Here is the fixed code:

    Please Login or Register  to view this content.
    Thanks again for your replies
    Last edited by candie025; 05-16-2014 at 09:00 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Delete Columns in Multiple Sheets with repeat macro

    Ah... I was on the right track, but you guys figured out the fix
    I see it was a need for the sheet reference... I just had it in the wrong place.

    Glad you solved it.

+ 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. Repeat Macro for multiple Sheets - Next without For
    By MelForsyth in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-14-2013, 03:57 AM
  2. Macro to Delete columns in different sheets within a workbook
    By makku in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2012, 09:38 AM
  3. Need macro help with transposing columns to rows and repeat a row value multiple times
    By InnovativeAJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2012, 11:53 AM
  4. Excel 2007 : Repeat Columns in multiple sheets
    By jbode in forum Excel General
    Replies: 1
    Last Post: 01-04-2011, 04:39 PM
  5. Macro to loop through all sheets and delete unwanted columns
    By LemonTwist in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2009, 12:03 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