![]() |
Search for a string, find the column and use that column to sort by
I have a data dump into excel, but the info doesn't dump into the same
column everytime, so I need to search the sheet for that string and once I find the column, use that column to sort the data. |
Search for a string, find the column and use that column to sort by
One way you may try is to record a macro while doing a manual
editFINDsort. Then modify. -- Don Guillett Microsoft MVP Excel SalesAid Software wrote in message ps.com... I have a data dump into excel, but the info doesn't dump into the same column everytime, so I need to search the sheet for that string and once I find the column, use that column to sort the data. |
Search for a string, find the column and use that column to sort by
Sub findSort()
Dim findWhat As String, col As Integer findWhat = "Johnny" On Error GoTo errHandler col = Cells.Find(What:=findWhat, After:=Cells(1, 1), _ LookIn:=xlFormulas, LookAt:=xlWhole, _ SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Column Cells.Sort Key1:=Columns(col), Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _ Orientation:=xlTopToBottom, DataOption1:=xlSortNormal Exit Sub errHandler: MsgBox findWhat & " not found" End Sub wrote: I have a data dump into excel, but the info doesn't dump into the same column everytime, so I need to search the sheet for that string and once I find the column, use that column to sort the data. |
Search for a string, find the column and use that column to sort by
Thanks a lot. I should have said filter instead of sort, but I think
I got it from here. |
All times are GMT +1. The time now is 11:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com