sort problem
Pete adding the sort order column was a great idea. I wish I had thought of
it! I was trying to do it based on a custom list. I would add the list but
my only reference to the list was by number and I couldn't count on everyone
using the macro having the same number of lists.
Thanks for you idea.
Mike
"Pete" wrote:
You seem to have Calc. Conc twice in the headings - if this is correct
then you have 7 columns of data, which I assume will occupy columns A
to G, with the headings in row 1. In your example you have 3 values for
Sample Type, i.e. "Standard", "Quality Control" and "Unknown", and you
want to get rid of any rows which have RB or PD in column A.
If I was doing this manually I would enter the heading "Sort_Order" in
cell H1 and in H2 the formula:
= IF ( OR(LEFT(A2,2) = "RB", LEFT(A2,2) = "PD"), "Z", IF (G2 =
"Standard", "A", IF(G2 = "Quality Control", "B", "C")))
Copy this formula down and fix the values using Copy | Edit | Paste
Special etc. If you have more than 3 Sample Types, you might think
about a lookup table to give you the sort orders.
Then select the block of data including the headings and sort on
Sort_Order and Sample Name. Any rows with RB or PD in column A will
appear at the bottom of the data (sorted as "Z") and these can be
deleted - set up a filter on column H for "Z" and Edit | Delete Row,
then remove the filter. You can then delete column H.
Most of this can be done by recording a macro from the keyboard as you
do it, then tweaking it in the VBA editor.
You could then have a little routine in a loop which compares A2 with
A3, A3 with A4 etc and inserts a blank row where these are not the
same, continuing until you reach the bottom of the data.
Hope this helps.
Pete
|