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.
Bookmarks