Thread
:
ummm, ummm, HELP!!!
View Single Post
#
20
Posted to microsoft.public.excel.misc
Sandy Mann
external usenet poster
Posts: 2,345
ummm, ummm, HELP!!!
You're Very welcome Curt.
do it. Just learning at my age is fun.
Learning at any age is fun - that's why I'm here.
--
Regards,
Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings
with @tiscali.co.uk
"Curt" wrote in message
...
Thanks for your post
Have gotten code to sort in order finally. Took a person better than me to
do it. Just learning at my age is fun.
Thanks again
Curt
"Sandy Mann" wrote:
"Curt" wrote in message
...
My results with countif has been that I get all 1's in a group then all
2's
If you mean you got that after you sorted on the Helper column then yes
that
is what I got. I then went on to sort the 1's only, sorting on column A.
If you mean that you got the numbers grouped together in the Helper
column
without having to sort on the Helper column then you don't have to sort
on
the Helper column. In either case when you get your data like:
A_____B______C
4__Other Data__1
3__Other Data__1
1__Other Data__1
2__Other Data__1
3__Other Data__2
1__Other Data__2
4__Other Data__2
2__Other Data__2
3__Other Data__3
4__Other Data__3
1__Other Data__3
2__Other Data__3
Highlight all data in all columns in the rows with the 1's grouped in the
Helper column, (C in the above example), and sort, (without headers), on
column A, then highlight all 2's in the Helper column etc.
--
HTH
Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings
with @tiscali.co.uk
"Curt" wrote in message
...
My results with countif has been that I get all 1's in a group then all
2's
in a group. Is not this what you got?
I needed a group that is 123456789 in order then another group and
another.
Thanks
"Sandy Mann" wrote:
Curt,
I don't know if this is what you are looking for but with my data
starting
in A5 I entered in a Helper column in the same row the formula:
=COUNTIF($A$5:A5,A5)
and copied down. I then highlighted all the data including the Helper
column and sorted on the Helper column. Next I highlighted all the
1's
and
sorted, (with no header), on columnn A, highlighted all the 2's etc.
You could write code to automate it but unless you have a great deal
of
data
then it would hardly be worth it.
--
HTH
Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings
with @tiscali.co.uk
"Curt" wrote in message
...
I have Vet's Day Parade entries that come in over time. Sometimes I
wonder
how I got hooked to do this. When you retire they ask for more!!!
Any
way
Excel only sorts 111222333 not, 123123123 so that is my problem
useing
column
(D) nbrs will be scrambled Need to sort into groups up tp 10 or so.
If
Parade
gets bigger will have to adjust later.What I am looking for is first
column.
I am stumped.
Not
1 1
2 1
3 2
4 2
1 3
2 3
3 4
4 4
Hope this tells story Let me know if it doesn't
Thanks
"CWillis" wrote:
Sorry about the late reply. Just got back from vacation. Could
you
give
me
a better description of the problem? Data-Sort-Descending should
sort
123...
I'm assuming your problem is more complex. Sample data and a goal
would
be
best.
-Chris
"Curt" wrote:
trying to sort consectlive 12345678 have entries in column D
scrambled
as
come in. Need to sort final as 12345678 from complete sheet. Can
this
be done?
Thanks
"CWillis" wrote:
Well, I ran out of time so it isn't finished, but it seems to
work
with the
data you gave me.
Quick explanation:
Finds the center of the circle (this is the biggest problem.
It
currently
finds the center by averaging all x's and all y's. This is
fine
as
long as
the points are nicely distributed around the circle. This will
cause
a
problem if most points are on one side for example.) After it
finds
the
center, it finds the angle of the imaginary line between the
center
and the
actual point. Using the angle, you can sort the data points so
they
come out
nice and neat when you plot them.
Here is what you need to do:
On a worksheet named "AutoSort", in row 1 starting with cell
one,
but
the
following titles:
X Value
Y Value
xdelta
ydelta
theta (degrees)
alt+f11 takes you into the vba screen. Paste the following
code:
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
Option Explicit
sub testing()
'Private Sub CommandButton1_Click()
Dim numpoints As Integer
Dim xsum
Dim ysum
Dim xaverage
Dim yaverage
Dim xdelta
Dim ydelta
Dim degadd As Integer
Dim i As Integer
Dim pi
'num points
Sheets("AutoSort").Range("A2").Select 'select first point
Selection.End(xlDown).Select 'get last point
numpoints = ActiveCell.Row - 1 'gets num points
'averages (current way of finding center of circle)
For i = 1 To numpoints
xsum = xsum + Sheets("autosort").Cells(i + 1, 1).Value
ysum = ysum + Sheets("autosort").Cells(i + 1, 2).Value
Next i
xaverage = xsum / numpoints
yaverage = ysum / numpoints
'xdelta and ydelta
For i = 1 To numpoints
Sheets("autosort").Cells(i + 1, 3).Value =
Sheets("autosort").Cells(i + 1, 1).Value - xaverage
Sheets("autosort").Cells(i + 1, 4).Value =
Sheets("autosort").Cells(i + 1, 2).Value - yaverage
Next i
'theta in degrees
pi = 4 * Atn(1) ' Calculate the value of pi.
For i = 1 To numpoints
xdelta = Sheets("autosort").Cells(i + 1, 3)
ydelta = Sheets("autosort").Cells(i + 1, 4)
'depending on quadrant, may have to add degrees
If xdelta 0 Then
If ydelta < 0 Then degadd = 360
End If
If xdelta < 0 Then degadd = 180
'display degree amount
Sheets("autosort").Cells(i + 1, 5).Value = degadd +
Atn(ydelta /
xdelta) * 180 / pi
'Sheets("autosort").Cells(i + 1, 5).Value = Atn(ydelta /
xdelta) *
180 / pi
Next i
End Sub
''''''''''''''''''''''''''''''''''''''''''''''
(You can make a button to run this if you so choose and then
just
uncomment
the second line.) Now, paste your data points under x value
and y
value and
run the code. It will display numbers under your column "theta
(degrees)".
Now, go to data, sort and sort by "theta (degrees)". Your plot
should work
when you plot the x and y values now.
Post any questions. I will be able to help on Monday.
Hope that helps.
-Chris
"phattony72" wrote:
Yeah, I know that a simple sort won't do it. I'm trying to
think
of
anything else that can be done.
I've included my sample set as a txt file (easy to open with
excel,
just comma delimited). It's ok with this one because there
are
only a
few points, but I will have others with thousands of points.
You'll
notice that the two LINE sets form vague circles (if you do a
simple
x-y scatter you can see this).
Thanks.
+-------------------------------------------------------------------+
|Filename: T1_2_outlines.txt
|
|Download:
http://www.excelforum.com/attachment.php?postid=5221
|
+-------------------------------------------------------------------+
--
phattony72
------------------------------------------------------------------------
phattony72's Profile:
http://www.excelforum.com/member.php...o&userid=37662
View this thread:
http://www.excelforum.com/showthread...hreadid=572700
Reply With Quote
Sandy Mann
View Public Profile
Find all posts by Sandy Mann