ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   data on top (https://www.excelbanter.com/excel-programming/397650-data-top.html)

[email protected]

data on top
 
hello ,

can anyone help with this,


i have series of data segregated like this

example:

richard
kenny
smith
john
raju

i want the output like this . i want smith to be positioned in the
first place always and should not be repeated

it should be like this

smith
richard
kenny
john
raju

can anyone help me with a formula

thans


Gary''s Student

data on top
 
Select your list and run:

Sub smith()
Dim savit()
ReDim savit(Selection.Count)
i = 0
foundit = False
For Each r In Selection
With r
If .Value = "smith" Then
foundit = True
Else
savit(i) = .Value
i = i + 1
End If
End With
Next

If foundit Then
i = 0
j = 0
For Each r In Selection
If j = 0 Then
Selection.Cells(1) = "smith"
j = 1
Else
r.Value = savit(i)
i = i + 1
End If
Next
End If
End Sub
--
Gary''s Student - gsnu2007


" wrote:

hello ,

can anyone help with this,


i have series of data segregated like this

example:

richard
kenny
smith
john
raju

i want the output like this . i want smith to be positioned in the
first place always and should not be repeated

it should be like this

smith
richard
kenny
john
raju

can anyone help me with a formula

thans



[email protected]

data on top
 
On Sep 18, 8:28 pm, Gary''s Student
wrote:
Select your list and run:

Sub smith()
Dim savit()
ReDim savit(Selection.Count)
i = 0
foundit = False
For Each r In Selection
With r
If .Value = "smith" Then
foundit = True
Else
savit(i) = .Value
i = i + 1
End If
End With
Next

If foundit Then
i = 0
j = 0
For Each r In Selection
If j = 0 Then
Selection.Cells(1) = "smith"
j = 1
Else
r.Value = savit(i)
i = i + 1
End If
Next
End If
End Sub
--
Gary''s Student - gsnu2007



" wrote:
hello ,


can anyone help with this,


i have series ofdatasegregated like this


example:


richard
kenny
smith
john
raju


i want the output like this . i want smith to be positioned in the
first place always and should not be repeated


it should be like this


smith
richard
kenny
john
raju


can anyone help me with a formula


thans- Hide quoted text -


- Show quoted text -


hi gary ,

thanks a lot ..




All times are GMT +1. The time now is 03:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com