VBA Macro - Automatic Sorting

Toncar58

New Member
Joined
Feb 24, 2021
Messages
30
Office Version
  1. 365
Platform
  1. MacOS
Hi

Can any help me please. I'm trying to automatically sort a column in alphabetical order using the following code

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("U:U")) Is Nothing Then
Range("IU1").Sort Key1:=Range("U2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

My data is in column "U" ... I used a similar code to automatically sot another worksheet in date order an it works perfectly.

When I first used the "Alphabetical" coding (which is the essence of my plea for help) it worked, but then I had to delete it (stupidly) and when I tried it again, it doesn't work.

Any help will be appreciated.

Toncar
 

Attachments

  • Screenshot 2021-07-30 at 14.50.31.png
    Screenshot 2021-07-30 at 14.50.31.png
    35.3 KB · Views: 7

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
The message tells you all you need to know. You have merged cells which are an abomination & should be avoided like the plague. Get rid of them.
 
Upvote 0
Thanks Fluff .... I am getting rid of the merged cells .... been told before to avoid merged cells ?? ...clearly advent learnt! will let you know once done. In the meantime thanks
 
Upvote 0
Thanks Fluff .... I am getting rid of the merged cells .... been told before to avoid merged cells ?? ...clearly advent learnt! will let you know once done. In the meantime thanks
Hi Fluff

As always thank you so much .... it works now .... and merged cells are now a thing of the past in my excel journey ... lol
Truly appreciate your help!
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,960
Messages
6,122,479
Members
449,088
Latest member
Melvetica

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