+ Reply to Thread
Results 1 to 11 of 11

Macro loop for "text to columns"

  1. #1
    Registered User
    Join Date
    09-16-2012
    Location
    Lausanne
    MS-Off Ver
    Excel 2007
    Posts
    20

    Macro loop for "text to columns"

    Hi everybody,

    Part of the problem I am going to present might sound trivial, but..
    I am trying to run a macro that for a series of sheets in a file should erase some columns and then separate in different columns the text one column (N) by when a semicolumn is present. I tried like this:

    Please Login or Register  to view this content.
    This has a first major problem: the command "text to column" seems not to loop among files.

    The second problem is not very important but: the different sheets are originally different files in a folder. Do I need always to group them together in the same file or there is an efficient way to loop across files directly in the folder?

    Thank you for any help,

    Stefano

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro loop for "text to columns"

    You can loop through files in a folder. You do not have to copy the data to multiple sheets and then action it.

    Do the same columns have to be deleted in all the files?
    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]

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Macro loop for "text to columns"

    You aren't using wks within the loop for the ranges.

    That can be fixed with some well placed dots.
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-16-2012
    Location
    Lausanne
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Macro loop for "text to columns"

    Thanks for the quick reply!
    yes, the same colums have to be deleted in all the files.
    Is the separetion of text in columns more problematic.
    (And, how can I loop through files?)
    Cheers,
    Stefano

  5. #5
    Registered User
    Join Date
    09-16-2012
    Location
    Lausanne
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Macro loop for "text to columns"

    Wow, this would be like the simple solution that seemed to be so difficult to find.
    I'll try right now!
    Thanks!

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro loop for "text to columns"

    The solution that Norie provided you will work well when the data is in multiple sheets of the same workbook.

    If you need to loop through files in a folder, you will need to use a different code.

  7. #7
    Registered User
    Join Date
    09-16-2012
    Location
    Lausanne
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Macro loop for "text to columns"

    I'm sorry to ask.. but could I have an hint about how to do it?
    If it is to time consuming to show, I'll try to document myself better (although I have already tried)
    and continue with the solution by Norie.
    Thanks,
    Stefano

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Macro loop for "text to columns"

    Stefano

    arlette is right, I think perhaps I misread your post.

    If you do have multiple files you want to run the code on you'll need to give us more information.

    eg where are the files located, which sheets in the files should the code run on

  9. #9
    Registered User
    Join Date
    09-16-2012
    Location
    Lausanne
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Macro loop for "text to columns"

    Great, thanks.. well
    1. the files are located in a folder; specifically with address:

    C:\Users\baruffal\Dropbox\Progetto_eth_epfl (3)\RAW_DATA\RAW_PUBS\Pubs_Stefano\Professors

    the code should run only on the first sheet of the files.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Macro loop for "text to columns"

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

  11. #11
    Registered User
    Join Date
    09-16-2012
    Location
    Lausanne
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Macro loop for "text to columns"

    Great!
    Thank you very much to both!

+ 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