How to Sort Data in Excel file using VBA
i am trying to Copy data from all Sheets to one sheet and Sor开发者_开发技巧t it Alphabetically.
My excel file contains CD names and Tracks, when i am sorting this data i m able to sort by CD Names but only first track of CD comes. rest of tracks are ignored.
please help me out for this.
Thanks in Advance....
Can't you use the sort
method of vba?
Besides, you can record a macro to create some code and adapt it to build a fully functional procedure.
Does your data look like this?
A B
CD1 Track1
Track2
Track3
CD2 Track1
Track2
Track3
If so, you need to fill in the blanks in column A. Select A2:A??? (as far down as your track data goes). Press F5 (Edit Goto), click Special Cells, Blanks. This will select all the blank cells in column A for your data.
Next, in A2, type =A1 and enter using Control+Enter. This will enter that formula in all the blank cells. Control+Enter enters an array formula. It's a way to enter a single formula in a bunch of cells at once. Your data should now look like
A B
CD1 Track1
CD1 Track2
CD1 Track3
CD2 Track1
CD2 Track2
CD2 Track3
Now select A1:A???. Edit - Copy. Edit- Paste Special - Values (don't change the selection - paste right over the existing data). Now if you sort on column A, all your CD1 tracks will be together.
精彩评论