I’m a complete newbie, and I have several problems that I hope you kind people could help with. I have been searching here for code that will help me and found some partial solutions. Here is problem #1
I have several files in C:\DATA about 30, but the number changes. All files have one sheet with data. The sheets have the same column headings, but not in the same order. So in File1 Name may be in column A, and in File2 it could be in column B. The files are sent to me so I’m not in control of the layout.
What I need is a macro that sorts the columns left to right for all files in the directory.
I know that Excel will do this, in Data, Sort, Options, Left to Right, but its time consuming to do this for 30 files.
Here is the code I found. Could someone modify it to repeat this for all files in a directory?
With ActiveSheet.UsedRange
For Each rw In .Rows
rw.Sort Key1:=Range("A" & rw.Row), Order1:=xlAscending, Orientation:=xlLeftToRight
Next rw
End With
End Sub
Your help would be appreciated
Thanks Don4000
I have several files in C:\DATA about 30, but the number changes. All files have one sheet with data. The sheets have the same column headings, but not in the same order. So in File1 Name may be in column A, and in File2 it could be in column B. The files are sent to me so I’m not in control of the layout.
What I need is a macro that sorts the columns left to right for all files in the directory.
I know that Excel will do this, in Data, Sort, Options, Left to Right, but its time consuming to do this for 30 files.
Here is the code I found. Could someone modify it to repeat this for all files in a directory?
With ActiveSheet.UsedRange
For Each rw In .Rows
rw.Sort Key1:=Range("A" & rw.Row), Order1:=xlAscending, Orientation:=xlLeftToRight
Next rw
End With
End Sub
Your help would be appreciated
Thanks Don4000