Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default How do I sort a table w/ merged cells

I have a 12 column table (cols B -M). Each row is formated the same and the
last 8 columns of each row (cols F thru M, all having a width of 9) are
merged into single cells in the row.

What code could I use to place the rows in alphabetic order, first by col C
and then by col B?

Whenever I try to sort this table manually using the Sort option on the Data
Ribbon, I get the error: This operation requires the merged cells to be
identically sized.

I appreciate your help, -John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default How do I sort a table w/ merged cells

Unmerge the cells in columns F-M, and set the column width of F to 72. Then
sort normally. All the data is in column F anyway; columns G-M are empty.

Hope this helps,

Hutch

"John" wrote:

I have a 12 column table (cols B -M). Each row is formated the same and the
last 8 columns of each row (cols F thru M, all having a width of 9) are
merged into single cells in the row.

What code could I use to place the rows in alphabetic order, first by col C
and then by col B?

Whenever I try to sort this table manually using the Sort option on the Data
Ribbon, I get the error: This operation requires the merged cells to be
identically sized.

I appreciate your help, -John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default How do I sort a table w/ merged cells

Tom, Good idea except my boss won't be too happy when I push all his summary
stats way to the right on the worksheet w/ the table! The rows above the
table contain a bunch of columns of summary data and the table spans these
rows. I had to merge all these cells in table rows in order to compensate
and do the table like my boss wants. There is a similar problem w/ data
below the table. I can't move the table to the right either since it has to
print in line w/ all the other data.

Sooo. How do I sort a table containing merged cells?

"Tom Hutchins" wrote:

Unmerge the cells in columns F-M, and set the column width of F to 72. Then
sort normally. All the data is in column F anyway; columns G-M are empty.

Hope this helps,

Hutch

"John" wrote:

I have a 12 column table (cols B -M). Each row is formated the same and the
last 8 columns of each row (cols F thru M, all having a width of 9) are
merged into single cells in the row.

What code could I use to place the rows in alphabetic order, first by col C
and then by col B?

Whenever I try to sort this table manually using the Sort option on the Data
Ribbon, I get the error: This operation requires the merged cells to be
identically sized.

I appreciate your help, -John

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default How do I sort a table w/ merged cells

Sorry if this posts twice. One way is to unmerge the cells, sort the table,
then re-merge the cells. Here is an example:

Sub SortTable()
Dim Tbl As Range
'Start with a cell in the table selected
'Select all the cells in the current region
Selection.CurrentRegion.Select
Set Tbl = Selection
'Unmerge all merged cells.
Selection.UnMerge
'Now sort the table
Tbl.Sort Key1:=Range("A5"), Key2:=Range("B5"), Header:=xlYes
'Walk down through each row of the table & re-merge cols F-M
Tbl.Cells(1, 1).Activate
Do While Not Intersect(ActiveCell, Tbl) Is Nothing
Range("F" & ActiveCell.Row & ":M" & ActiveCell.Row).Merge
ActiveCell.Offset(1, 0).Activate
Loop
'Free the object variable
Set Tbl = Nothing
End Sub

You would have to edit the Sort command parameters, of course. You also may
need to use something other than CurrentRegion to specify the table range.

Hutch

"John" wrote:

Tom, Good idea except my boss won't be too happy when I push all his summary
stats way to the right on the worksheet w/ the table! The rows above the
table contain a bunch of columns of summary data and the table spans these
rows. I had to merge all these cells in table rows in order to compensate
and do the table like my boss wants. There is a similar problem w/ data
below the table. I can't move the table to the right either since it has to
print in line w/ all the other data.

Sooo. How do I sort a table containing merged cells?

"Tom Hutchins" wrote:

Unmerge the cells in columns F-M, and set the column width of F to 72. Then
sort normally. All the data is in column F anyway; columns G-M are empty.

Hope this helps,

Hutch

"John" wrote:

I have a 12 column table (cols B -M). Each row is formated the same and the
last 8 columns of each row (cols F thru M, all having a width of 9) are
merged into single cells in the row.

What code could I use to place the rows in alphabetic order, first by col C
and then by col B?

Whenever I try to sort this table manually using the Sort option on the Data
Ribbon, I get the error: This operation requires the merged cells to be
identically sized.

I appreciate your help, -John

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
How can I sort an Excel Doc containing merged & non-merged cells? KellyH Excel Discussion (Misc queries) 11 June 10th 08 04:12 AM
Sort - Merged cells ED New Users to Excel 2 May 24th 07 05:10 PM
How to sort merged cells Sort merged cells Excel Worksheet Functions 3 March 11th 05 04:07 PM
How to sort merged cells imaorange Excel Worksheet Functions 0 March 11th 05 03:41 PM
Sorting merged cellsHow do I sort merged cells not identically siz Laval Excel Worksheet Functions 1 November 3rd 04 09:40 PM


All times are GMT +1. The time now is 03:10 AM.

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

About Us

"It's about Microsoft Excel"