VBA: sort formulas instead of values

zeno

Board Regular
Joined
Feb 16, 2012
Messages
71
Hello,

I'm trying to sort a column from high to low and I have the VBA code for this.
However, because the column to be sorted has formulas, that does not really work. Can you change the VBA so that the sorting would happen on the values of these formulas instead? For the moment I do not wish to change these formulas into values though.

This is the VBA code I have:

Code:
'Set the range variable to the column you'll be sorting
    Set rngP = Range("Q3", Cells(Rows.coUnt, "Q").End(xlUp))
'Store the unsorted data in an array
    arr2PUnsorted = rngP.Value
'Sort the range descending, put the sorted data 1 column over
    rngP.Sort rngP, xlDescending, Header:=xlNo
    rngP.Offset(, 2).Value = rngP.Value
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What kind of formulas do you have?
Is there any reason that you shouldn't convert the formulas into values before sorting?
 
Upvote 0
These are sums and divisions. Nothing complicated. I can potentially add a column where I put the formulas into values. I'm just wondering if there is a way to go from the formulas into sorting the corresponding values?
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,930
Members
452,367
Latest member
TePunaBloke

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