automatic sorting

lm4

New Member
Joined
May 20, 2011
Messages
7
Hello,

I would like to sort these averages in ascending order . I can do this with the A-Z but i would like this to be done automatically when I add data in the sheet average depends on . The averages appear as "#DIV/0!" right now as there is no data in the other sheet yet.

# GRUPOS
0 DATA Average
1 Aritama #DIV/0!
3 Força de Fibra #DIV/0!
4 Associação Ressurgir #DIV/0!
5 Azuleijaria #DIV/0!
6 Canoarte #DIV/0!
7 Cerâmica negra - ACB #DIV/0!
8 Cestaria Botânica #DIV/0!
9 Ciclo Ambiental #DIV/0!
10 Costurando Ideais #DIV/0!
11 Criola #DIV/0!
12 Fuxicarte #DIV/0!
13 Toque de Mãos #DIV/0!
14 Martesãs #DIV/0!
15 AcomB #DIV/0!
16 Mulher em Ação #DIV/0!
17 Nó e Nós #DIV/0!
18 Nós da Trama #DIV/0!
19 Nosso Papel #DIV/0!
21 MãosBrasil #DIV/0!
22 Atelier Spinelli #DIV/0!
23 ArteJor #DIV/0!
24 Fio Nobre #DIV/0!
25 Trama e Raiz #DIV/0!
28 Recult #DIV/0!
29 Cooperativa de Friburgo #DIV/0!
30 Bordados de Natividade #DIV/0!
31 Banco da Providência #DIV/0!
32 Retalhos e Bordados #DIV/0!


Thank you
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Welcome to the Board!

Record a macro applying the sort that you want. You can call the sort routine from a Change event. Here's some boilerplate Change code you can adapt:

<font face=Calibri><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br>    <SPAN style="color:#007F00">'   Code goes in the Worksheet specific module</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> rng <SPAN style="color:#00007F">As</SPAN> Range<br>        <SPAN style="color:#007F00">'   Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")</SPAN><br>        <SPAN style="color:#00007F">Set</SPAN> rng = Target.Parent.Range("xxx")<br>             <SPAN style="color:#007F00">'   Only look at single cell changes</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> Target.Count > 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>            <SPAN style="color:#007F00">'   Only look at that range</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> Intersect(Target, rng) <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>            <SPAN style="color:#007F00">'   Action if Condition(s) are met (do your thing here...)</SPAN><br>            <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

HTH
 
Upvote 0
I'm afraid I am a bit lost ...

Is there any way I can attach the document on this forum ?
Thank you
 
Upvote 0
What are you having a hard time with?

Sorry, you can't attach documents here, but you can post screen shots - see the link in my sig.
 
Upvote 0
Not really, sorry, then you lose the reach of the entire board helping you vs. just me.

What problem are you having? Is it an issue of understanding the code? If so, we can walk you through that.
 
Upvote 0
Well I don't know what to put in the macro, I have never used a macro in my life and I can't manage to screen shot my excel file into this forum either unfortunately..

I have one sheet with averages and the second sheet is the list of averages and the companies each average belongs to. I would like to sort them in ascending order but I don't really know what to put in the macro.
 
Upvote 0
Right-click on the sheet tab where you want the sorting to take place and select View Code, then paste the code in the new window that opens on the right.

You'll need to change the "xxx" part in the code to be the actual range you want to evaluate for changes. E.G. if you want the sort to happen when you've added data in column B, you'd change it to ("B:B").

Then at the bottom after where it says "Do your thing here", call the sorting macro you recorded:

Call MacroName

Then you can exit back to Excel to try it.
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,513
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top