Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default 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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search text string for ssn and copy to new column mary Excel Discussion (Misc queries) 8 December 28th 07 03:13 AM
Please let Excel sort by string value within the cell/column. Kraig Excel Programming 2 July 24th 06 06:03 PM
search a string withing a string : find / search hangs itarnak[_9_] Excel Programming 4 October 24th 05 03:19 PM
URGENT -- search in string for a value in another column, if found, return value from next column samkshah Excel Programming 4 October 3rd 05 04:13 PM
Search column - return row found in long text string JayL Excel Programming 1 March 5th 05 03:23 AM


All times are GMT +1. The time now is 04:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"