Random Results when sorting using VBA?

RedOctoberKnight

Board Regular
Joined
Nov 16, 2015
Messages
150
Office Version
  1. 2016
Platform
  1. Windows
Good Morning.

I'm racking my brain trying to understand what is going on but I cant seem to figure it out.

I have the following code that I want to sort the range by Last Name in Alphabetical Order.

VBA Code:
Sub sort_CSA()
Range("A6:T74").Sort KEY1:=Range("B6"), order1:=xlAscending, Header:=xlYes
End Sub

Last names are in column B starting in cell B7. I have a headers in row 6.

I cant figure out why but every time I run it, I get a different random order in Column B.

Anybody have any suggestions?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Do you have a formula in col B?
 
Upvote 0
Does the formula refer to the name of the sheet it's on?
 
Upvote 0
Is that on the "Master" sheet?
 
Upvote 0
In that case use
Excel Formula:
=INDEX('PHONE LIST'!$C$4:$C$72,MATCH(A14,'PHONE LIST'!$B$4:$B$72,0))
you should never refer to the sheet name the formula is on.
 
Upvote 0
Solution
wow, thank you! I had no idea that would cause such an issue! Would you mind explaining to me why that happens?
 
Upvote 0
I've no idea why it happens, just that it does.
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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