Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Convert Text to Columns | Excel Worksheet Functions | |||
convert text to columns | Excel Discussion (Misc queries) | |||
Convert text to columns | Excel Discussion (Misc queries) | |||
Convert text date to general number | Excel Discussion (Misc queries) | |||
convert text to columns | Excel Discussion (Misc queries) |