+ Reply to Thread
Results 1 to 3 of 3

Manipulating VBA Text To Columns

Hybrid View

  1. #1
    Registered User
    Join Date
    08-27-2008
    Location
    United States
    Posts
    45

    Manipulating VBA Text To Columns

    Hello,

    I have the following code:

        Selection.TextToColumns Destination:=Range("A7"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
            :="%", FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2)), _
            TrailingMinusNumbers:=True
    I have bolded the relevant text. I am wondering if there is a way to specify ALL columns have the value 2 instead of just the ones that I have listed there. Otherwise I will have to go

    Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 2), Array(7, 2), Array(8, 2), Array(9, 2), Array(10, 2), Array(11, 2), Array(12, 2), Array(13, 2), Array(14, 2), Array(15, 2)
    and etc.

    Thanks in advance!

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    Hi googlebot

    I don't think there's a solution inside the TextToColumns method. You can, however, use an array:

    Dim ary
    
        ary = [if({1,0},row(1:15),2)]
        
        Selection.TextToColumns Destination:=Range("A7"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
            :="%", FieldInfo:=ary, TrailingMinusNumbers:=True

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

    Re: Manipulating VBA Text To Columns

    Post removed
    Last edited by pike; 09-19-2009 at 07:14 AM. Reason: invaled entry
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ 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