Sort Question

misho

New Member
Joined
Sep 12, 2002
Messages
1
I have a list of prioritized items in Excel 98. In the first column is the priority number, 1 through x. sometimes I will need to change a priority number, say make a new item that is priority 1, making the old priority number 1 into 2, 2 into 3, etc. How can this be done?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi Misho,

Well, here is one way. Simply select the cells containing the old priority numbers and run the macro below. It will add 1 to each of the selected cells.

Sub Add1()
For Each Cell In Selection
Cell.Value = Cell.Value + 1
Next Cell
End Sub

If you don't know how to install a VBA macro, it's really
quite easy. Just follow these steps:

1) Go to the Visual Basic Editor (VBE). Do this from Tools >
Macro > Visual Basic Editor (or simply keyboard Alt-TMV)

2) In the VBE create a new Macro Module: Insert > Module.
An empty code window pane will appear (Alt-IM).

3) Paste the code into this window. The macro or function is
now available for use from Excel. If it is a Function type
macro you can immediately use it as an Excel function. If
it is a Sub (subroutine) type macro you can run it from
the Excel Tools > Macro menu (Alt-TMM).
 

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
If you can use an extra column, you could use this formula.

Say for example that your priorities are in A1:A10, then in B1:B10 put this:

=RANK(A1,$A$1:$A$10,1)+COUNTIF($A$1:A1,A1)-1
 

Forum statistics

Threads
1,148,028
Messages
5,744,400
Members
423,867
Latest member
mahenderkongari

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
Top