Hving a Macro meltdown, help

bionicle

Board Regular
Joined
Apr 23, 2009
Messages
186
Office Version
  1. 365
Platform
  1. Windows
Hi All,

having issues in getting a macro to work the way I want it to.

my spread sheet has columns A-CO being used and rows 1-199. Row 1 is the column headings.

I have a macro that sorts column K alphabetically whoever in doing so it has reversed it so instead of starting at "A****" in column K it starts with "W****"

I have tried to swap the descending and ascending order around which works and the Column does in deed then starts at "A****" but it also starts in row 70 for some unknown reason.

any help would be gratefully received.

my macro is as follows:

Sub Macro1()
Range("A2:co199").Select
Selection.Sort Key1:=Range("k2:k199"), Order1:=xlDescending, Key2:=Range("k2:k199") _
, Order2:=xlAescending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom
End Sub
 
Last edited:
miss communication here. column 'K' cell K2 has the following formula: ='Labour Load'!F17 and K3 has ='Labour Load'!F18
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
the spreadsheet name is planner, this is the one I'm working in Labour Load is where the data is being pulled from
 
Upvote 0
quote_icon.png
Originally Posted by Peter_SSs 1. Could you please post the formula that is in cell K2 and the formula that is in cell K69? K2 ='Labour Load'!F17 & K69 ='Labour Load'!F84

2. What is the name of the worksheet that this data being sorted is on The sheet where the data is to be sorted is called 'Planner'
 
Upvote 0
Thank you.

I have set up a 'Labour Load' sheet with random text data in column F starting in row 17.
My 'Planner' sheet has
- headings in row 1 (K1:CO1)
- the formula in K2: ='Labour Load'!F17 and this copied down to K199
- random data in L2:CO199

After running the exact code from post 6, the data in column K is in alphabetical order.
Because of the sorting of the values in the cells, the formulas in column K are now like ..
K2: ='Labour Load'!F129
K3: ='Labour Load'!F105
K4: ='Labour Load'!F58
etc

As far as I understand it, that is what you want.

If you are not getting that ..

Are you sure there isn't something different to what you have stated so far?

Did you modify my code in any way or combine it with other code that you have?
 
Upvote 0

Forum statistics

Threads
1,216,759
Messages
6,132,556
Members
449,735
Latest member
Gary_M

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