+ Reply to Thread
Results 1 to 2 of 2

Macro for Text to Columns - convert to text or general

  1. #1
    goofy11
    Guest

    Macro for Text to Columns - convert to text or general

    I frequently have to change the format of columns to either text or general.
    Normally I highlight the column and go through the Text to Columns wizard and
    make the conversion. It would save me time if all I had to do was select the
    column and click a button to run a macro that would through the Text to
    Columns wizard. I have limited knowledge of VBA, but frequently record
    macros. I tried to record a macro to do the above mentioned task, but ran
    into a problem. After selecting a column, I began recording the macro. I
    simply went through the Text to Columns wizard and stopped recording. The
    column I had randomly selected happened to be column A. After testing the
    macro, I realized that the macro always applied the Text to Columns to column
    A, regardless of the column I selected. After looking at the code, I saw
    that column A was written into the code. Is there any way to create a macro
    that will apply the Text to Columns to whichever column I highlight before
    running the macro. I would like to create one that converts the column to
    text and another that converts it to general. Here's what my VBA code looked
    like after recording the macro:

    Selection.TexttoColumns Destination:=Range("A1"), DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
    Tab:=True, _
    Semicolon:=False, Comma:=False, Space:=False, Other:=False,
    FieldInfo _
    :=Array(1, 1), TrailingMinusNumbers:=True
    Range("A1").Select
    End Sub

    Any help would be appreciated.

    Thanks.

  2. #2
    Tom Ogilvy
    Guest

    Re: Macro for Text to Columns - convert to text or general

    Selection.TexttoColumns Destination:=selection.Cells(1,1), _
    DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, _
    ConsecutiveDelimiter:=False, _
    Tab:=True, _
    Semicolon:=False, _
    Comma:=False, _
    Space:=False, _
    Other:=False, _
    FieldInfo:=Array(1, 1), _
    TrailingMinusNumbers:=True

    End Sub

    --
    Regards,
    Tom Ogilvy



    "goofy11" <goofy11@discussions.microsoft.com> wrote in message
    news:78511329-5832-4F90-A619-ACF524FA67AA@microsoft.com...
    > I frequently have to change the format of columns to either text or

    general.
    > Normally I highlight the column and go through the Text to Columns wizard

    and
    > make the conversion. It would save me time if all I had to do was select

    the
    > column and click a button to run a macro that would through the Text to
    > Columns wizard. I have limited knowledge of VBA, but frequently record
    > macros. I tried to record a macro to do the above mentioned task, but ran
    > into a problem. After selecting a column, I began recording the macro. I
    > simply went through the Text to Columns wizard and stopped recording. The
    > column I had randomly selected happened to be column A. After testing the
    > macro, I realized that the macro always applied the Text to Columns to

    column
    > A, regardless of the column I selected. After looking at the code, I saw
    > that column A was written into the code. Is there any way to create a

    macro
    > that will apply the Text to Columns to whichever column I highlight before
    > running the macro. I would like to create one that converts the column to
    > text and another that converts it to general. Here's what my VBA code

    looked
    > like after recording the macro:
    >
    > Selection.TexttoColumns Destination:=Range("A1"), DataType:=xlDelimited, _
    > TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
    > Tab:=True, _
    > Semicolon:=False, Comma:=False, Space:=False, Other:=False,
    > FieldInfo _
    > :=Array(1, 1), TrailingMinusNumbers:=True
    > Range("A1").Select
    > End Sub
    >
    > Any help would be appreciated.
    >
    > Thanks.




+ 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