help, what have i done wrong with these data sort macro?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,

I tried his is my macro

writing the data sort macro but it doesn't work,
what I'm trying to do is make it easy for me to go in and edit the cell range and the sort column as I have a lot of these to right, so I thought id do it by seting the column it sorts by and the cell range at the top and using the words as the ranges in the code, belive me when I tell you this is needed!!!

the problem is it doesn't work? can someone please fix it or tell me what I did wrong?

this is my macro:

Code:
End Sub
Sub Macro6()
'
Dim oneRange As Range
Dim aCell As Range

Set oneRange = Range("H4:L7")
Set aCell = Range("I4:I7")
bCell = "xlAscending"
oneRange.Sort Key1:=aCell, Order1:=bCell, Header:=xlGuess
   
End Sub

so for the moment all I want is a macro that sorts range H4:L7 by column I in Assending order.
please help

thanks

Tony
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
The error appears to be the use of bCell, the following works fine for me:
Rich (BB code):
Sub Macro6()

Dim oneRange As Range
Dim aCell As Range

Set oneRange = Range("H4:L7")
Set aCell = Range("I4:I7")
bcell = "xlAscending"

oneRange.Sort key1:=aCell, order1:=xlAscending, Header:=xlGuess
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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