Results 1 to 6 of 6

Loop through worksheets when splitting text to columns

Threaded View

  1. #1
    Registered User
    Join Date
    01-26-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Loop through worksheets when splitting text to columns

    I am rather new in coding, so I hope there is someone that can help me with this problem. The code is supposed to do the following: Go through each worksheet and split the text (in column A4 and down) into three separate columns. The split into columns is made right, but when playing the macro the code only does it for the active worksheet - and does not loop through all of the worksheets.

    Dim wkSheet As Worksheet
    
    For Each wkSheet In Worksheets
        Range(Range("a4"), Range("a4").End(xlDown)).Select
        Selection.TextToColumns Destination:=Range("A4"), DataType:=xlFixedWidth, _
            OtherChar:=":", FieldInfo:=Array(Array(0, 1), Array(10, 1), Array(20, 1))
        Range(Range("c4"), Range("c4").End(xlDown)).Select
        Selection.TextToColumns Destination:=Range("C4"), DataType:=xlDelimited, _
            TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=False, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
            :=":", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
            1))
    Next wkSheet
    Highly appreciate any help. Thank you

    Moderators Note:
    • Please follow Forum Rule #3 and use code tags.
    • Added this time, but please use them in the future…Thanks.
    Last edited by jeffreybrown; 01-26-2013 at 11:50 AM.

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