VBA Sorting due to Formula

Wardylewis

New Member
Joined
Jun 7, 2016
Messages
37
Good Afternoon,

I have created a sheet which pulls information from another sheet to generate an easy to read plan.


However due to the formulas in the cell is
Code:
=IFERROR(LOOKUP(2,1/('Data Input'!$A$1:$A$2500='Live Check'!$A661),'Data Input'!$R$1:$R$2500),"No Records Held")

When I do a standard sort it works for a split second and then changes and gives me a different result every time I sort.

I have tried to take a look online to edit the Macro I have done but am really struggling to get my head around it.

Code:
Sub Sort()'
' Sort Macro
'


'
Dim rangeToSort As Range


    ActiveWorkbook.Worksheets("Live Check").ListObjects("Table1").Sort.SortFields. _
        Clear
    ActiveWorkbook.Worksheets("Live Check").ListObjects("Table1").Sort.SortFields. _
        Add Key:=Range("Table1[[#All],[Next Test Date]]"), SortOn:= _
        xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Live Check").ListObjects("Table1").Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub

Any help would be greatly appreciated.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Doing some additional tests it seems to be only affected when formatted in a table.

Apart from removing this formatting is there any other way around it?
 
Upvote 0
What happens if you remove the part in blue
=IFERROR(LOOKUP(2,1/('Data Input'!$A$1:$A$2500='Live Check'!$A661),'Data Input'!$R$1:$R$2500),"No Records Held")
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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