Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 36
Default Sorting the first text in a row

I have 4 columns with names, in some rows are none to 4 names. The names
appear random in any of the columns. It could look like this:
name1 name2
name3
name 4 name5

I want to get the first name that appears (from left to right) and put it in
the fifth column, like this:
name1
name3
name4

I can't figure it out, any help is welcome
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Sorting the first text in a row

One way
'=======
Option Explicit
Sub getleftmostcell()
Dim lr As Long
Dim i As Long
'finds last row
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
'gets cell
For i = 1 To lr
If Len(Application.Trim(Cells(i, 1))) 0 Then
Cells(i, 5) = Cells(i, 1)
Else
Cells(i, 5) = Cells(i, 1).End(xlToRight)
End If
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Hans" wrote in message
...
I have 4 columns with names, in some rows are none to 4 names. The names
appear random in any of the columns. It could look like this:
name1 name2
name3
name 4 name5

I want to get the first name that appears (from left to right) and put it
in
the fifth column, like this:
name1
name3
name4

I can't figure it out, any help is welcome


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 236
Default Sorting the first text in a row

Assuming the data is in columns A thru D...
=IF(LEN(A1)<0,A1,IF(LEN(B1)<0,B1,IF(LEN(C1)<0,C 1,D1)))
--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Hans" wrote:

I have 4 columns with names, in some rows are none to 4 names. The names
appear random in any of the columns. It could look like this:
name1 name2
name3
name 4 name5

I want to get the first name that appears (from left to right) and put it in
the fifth column, like this:
name1
name3
name4

I can't figure it out, any help is welcome

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Sorting the first text in a row

=IF(COUNTA(1:1),INDEX(1:1,MATCH("*",1:1,0)),"")


"Hans" wrote:

I have 4 columns with names, in some rows are none to 4 names. The names
appear random in any of the columns. It could look like this:
name1 name2
name3
name 4 name5

I want to get the first name that appears (from left to right) and put it in
the fifth column, like this:
name1
name3
name4

I can't figure it out, any help is welcome

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
Sorting different strings of text Jake New Users to Excel 2 September 8th 08 05:30 PM
Sorting (Numbers with Text) JSpence2003 Excel Discussion (Misc queries) 8 August 31st 07 10:30 PM
help with text sorting jjcx Excel Worksheet Functions 6 August 1st 06 03:58 PM
Sorting Text sparx Excel Discussion (Misc queries) 0 June 19th 06 09:47 PM
sorting of text confusded Excel Discussion (Misc queries) 1 July 27th 05 04:58 PM


All times are GMT +1. The time now is 09:33 PM.

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

About Us

"It's about Microsoft Excel"