![]() |
Data Split and sort problem
To all,
I have a list of data in column A: eg: L1 L2 M2 M7 H7 H10 L6 L8 M6 M99 etc I want to be able to split the data in column A into three columns: All the data starting with 'L' in column B, i.e. L1,L2, L6,L8 All the data starting with 'M' in column C i.e., M2, M7, M6 All the data starting with 'H' in column D i.e. H10 I would like the data to be sorted in each column. Can this be done using a macro? Thanks for all your help in advance, Kind Regards Joseph Crabtree |
Data Split and sort problem
Perfect. Many Thanks.
On Dec 20, 3:30 pm, John Bundy remove X''''s wrote: You can sort the column before then add this to code it will do them in order. This assumes there are no blanks in column A Sub main() Dim myRow, bRow, cRow, dRow As Integer bRow = 1 cRow = 1 dRow = 1 myRow = 1 Do Until Cells(myRow, 1) = "" If Left(Cells(myRow, 1), 1) = "L" Then Cells(bRow, 2) = Cells(myRow, 1) bRow = bRow + 1 End If If Left(Cells(myRow, 1), 1) = "M" Then Cells(cRow, 3) = Cells(myRow, 1) cRow = cRow + 1 End If If Left(Cells(myRow, 1), 1) = "H" Then Cells(dRow, 4) = Cells(myRow, 1) dRow = dRow + 1 End If myRow = myRow + 1 Loop End Sub -- -John Please rate when your question is answered to help us and others know what is helpful. "joecrabtree" wrote: To all, I have a list of data in column A: eg: L1 L2 M2 M7 H7 H10 L6 L8 M6 M99 etc I want to be able to split the data in column A into three columns: All the data starting with 'L' in column B, i.e. L1,L2, L6,L8 All the data starting with 'M' in column C i.e., M2, M7, M6 All the data starting with 'H' in column D i.e. H10 I would like the data to be sorted in each column. Can this be done using a macro? Thanks for all your help in advance, Kind Regards Joseph Crabtree- Hide quoted text -- Show quoted text - |
All times are GMT +1. The time now is 05:30 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com