Excel Macro

G

Guest

I have an excel spreadsheet in which I need to sort row with column headings
that are mixed between merged and unmerged cells. In other words, I have
merged columns for employee name, project number, id and then have additional
columns that have beginning date range and ending date range stacked. These
last date ranges cannot be merged.
Right now the macro gives an error message of "merged cells must be of
identical sizes". Any way to work around this?
 
O

Otto Moehrbach

The way to work around what you have is to get rid of all merged cells.
What you see in your file is another example of why you should never use the
merge cells feature. Period.
You can accomplish the same appearance in your file by other means. Do
this: Open a new blank file. In A1 enter something. Anything. Now select
A1:H1. Now click on Format - Cells - Alignment tab. In the "Horizontal:"
space click on the down-arrow and click on "Center across selection". Done.
HTH Otto
 
D

Don Guillett

Sub CENTERACROSS()'toggles in personal.xls assigned to menu button
With Selection
If .HorizontalAlignment = xlCenterAcrossSelection Then
.HorizontalAlignment = xlGeneral
Else
Selection.HorizontalAlignment = xlCenterAcrossSelection
End If
End With
End Sub

Sub CenterAcrossA()
Selection.HorizontalAlignment = xlCenterAcrossSelection
End Sub
 
G

Guest

Thanks Otto, however my explanation probably wasn't clear enough as the
center across doesn't work. here is an example portion of the spreadsheet:

Employee ID Project 9/1 9/8 9/15
9/7 9/14 9/21
Joe Smith 777 ABCDE 20 24 30
Mary Doe 888 xyzrr 16 12 10


I can't sort this without losing the date range that I need to keep in tact.
 
O

Otto Moehrbach

Rick
It's not clear in your post what's in what row/column. I understand the
Employee, ID, and Project and the entries under that, but I don't understand
where all the dates and numbers go. Where does all that go and exactly what
cells are merged and what cells aren't merged. Be specific, like cell A5
has this, cell B5 has that, etc. Then tell us by what column you are trying
to sort. Tell us what is sorting properly and what is not. HTH Otto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top