Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Text to Columns Eán[_2_] Excel Worksheet Functions 1 October 28th 09 10:44 AM
convert text to columns Paul Excel Discussion (Misc queries) 2 September 11th 09 06:14 PM
Convert text to columns NWI Excel Discussion (Misc queries) 3 September 2nd 07 11:57 PM
Convert text date to general number Andrew Excel Discussion (Misc queries) 6 July 19th 07 09:03 AM
convert text to columns Cindi Excel Discussion (Misc queries) 6 November 6th 06 09:14 PM


All times are GMT +1. The time now is 03:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"