+ Reply to Thread
Results 1 to 6 of 6

Usage of for loop with increment in no particular order

  1. #1
    Registered User
    Join Date
    09-23-2011
    Location
    Calcutta
    MS-Off Ver
    Excel 2007
    Posts
    26

    Usage of for loop with increment in no particular order

    Hi,

    I need to delete a large number of columns that are in no particular order.

    I wish to write a for loop like this:

    Please Login or Register  to view this content.
    Can someone suggest a looping to delete all these columns without having to type Column(x).delete for each x?
    Something like, where I could just type all the numbers at one place and use Column(x).delete in a loop?
    Last edited by drajanm; 11-21-2011 at 07:06 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,327

    Re: Usage of for loop with increment in no particular order

    Hi drajanm
    you can use an array

    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    36,269

    Re: Usage of for loop with increment in no particular order

    Maybe:

    Please Login or Register  to view this content.

    Regards
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    36,269

    Re: Usage of for loop with increment in no particular order

    @Pike:

    won't your code delete the wrong columns as you're going from left to right?

    Regards, TMS

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,327

    Re: Usage of for loop with increment in no particular order

    Hi TMShucks
    Thanks
    Please Login or Register  to view this content.

  6. #6
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,327

    Re: Usage of for loop with increment in no particular order

    or

    Please Login or Register  to view this content.

+ 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