data on top

  • Thread starter Thread starter k743911
  • Start date Start date
K

k743911

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
 
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
 
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









- Show quoted text -

hi gary ,

thanks a lot ..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top