K
KellyinCali
I am using a macro to reformat a txt file which was exported from a
proprietary program and opened with Excel. The sort works fine, but I
recorded the macro to get the code and when it sorts by column A, the
recorded code references the specific worksheet name which was automatically
named for the txt file name. Problem is that subsequent txt files will
always have a different name. I just need the wording to make it for
whatever the current sheet is.
TIA,
Kelly
The recorded code came out like this:
Columns("A:F").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("QSYSPRT732957").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("QSYSPRT732957").Sort.SortFields.Add
Key:=Range( _
"A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("QSYSPRT732957").Sort
.SetRange Range("A1:F300")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
proprietary program and opened with Excel. The sort works fine, but I
recorded the macro to get the code and when it sorts by column A, the
recorded code references the specific worksheet name which was automatically
named for the txt file name. Problem is that subsequent txt files will
always have a different name. I just need the wording to make it for
whatever the current sheet is.
TIA,
Kelly
The recorded code came out like this:
Columns("A:F").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("QSYSPRT732957").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("QSYSPRT732957").Sort.SortFields.Add
Key:=Range( _
"A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("QSYSPRT732957").Sort
.SetRange Range("A1:F300")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With