![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 03:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com