#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 313
Default VBA Sort Problem

I have five different areas on a worksheet that I want to sort separately.
When it gets to the fourth section ("A43:f" & DMcnt), I get the following
error message:

"RunTime Error 1004
This operation requires the merged cells to be identically sized."

Not sure what I am doing wrong, any suggestions?

I use the following code for each group like this:

With Worksheets("CASB-Toronto Central Phone List").Range("a12:f" & AMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a21:f" & BMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a33:f" & CMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a43:f" & DMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a50:f" & EMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo
End With
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default VBA Sort Problem

You have merged cells in that range.

Reformat the cells to remove the merged cells.

In xl2003 menus,
select the range
format|cells|alignment tab|uncheck merge cells



Tony wrote:

I have five different areas on a worksheet that I want to sort separately.
When it gets to the fourth section ("A43:f" & DMcnt), I get the following
error message:

"RunTime Error 1004
This operation requires the merged cells to be identically sized."

Not sure what I am doing wrong, any suggestions?

I use the following code for each group like this:

With Worksheets("CASB-Toronto Central Phone List").Range("a12:f" & AMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a21:f" & BMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a33:f" & CMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a43:f" & DMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a50:f" & EMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo
End With


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default VBA Sort Problem

sounds like there is a merge cell somewhere in the list in the sheet, it is
probably not your VBA but the spreadsheet that has the problem. Try
highlighting all the cells in the fourth area and take all merge options off.

Craig

"Tony" wrote:

I have five different areas on a worksheet that I want to sort separately.
When it gets to the fourth section ("A43:f" & DMcnt), I get the following
error message:

"RunTime Error 1004
This operation requires the merged cells to be identically sized."

Not sure what I am doing wrong, any suggestions?

I use the following code for each group like this:

With Worksheets("CASB-Toronto Central Phone List").Range("a12:f" & AMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a21:f" & BMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a33:f" & CMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a43:f" & DMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
With Worksheets("CASB-Toronto Central Phone List").Range("a50:f" & EMcnt)
.Sort _
Key1:=.Columns(6), _
Order1:=xlAscending, _
Header:=xlNo
End With

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! I am having a problem with sort! RobertD[_2_] Excel Discussion (Misc queries) 2 August 29th 08 07:56 PM
Sort Problem Trish[_2_] Excel Discussion (Misc queries) 1 March 25th 08 11:51 AM
A "sort" problem comotoman Excel Discussion (Misc queries) 1 September 28th 05 10:48 PM
Sort Problem andyp161 Excel Worksheet Functions 1 September 5th 05 12:19 PM
Sort Problem jdb Excel Discussion (Misc queries) 1 January 10th 05 11:05 PM


All times are GMT +1. The time now is 04:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"