Sortng data with rows of differnt heights. etc

Mabocat

Board Regular
Joined
Apr 20, 2011
Messages
74
I have a spreadsheet page made of 14 columns and on average 60 rows - some are standard height & others larger and is planned to be sorted on a time of hours & minutes based on one column.
Currently I cut and paste the rows because i had merged cells. After reformatting the cells, I now have a macro that sorts the data OK but the row formatting of height is ruined.

Is it possible to sort data ( meaning the rows) and maintain the row formatting ? if so, what do I do to change my macro
Code:
     With Worksheets("Tawnton")
       .Sort.SortFields.Clear
    .Sort.SortFields.Add Key:=Range("Tawnton_time"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With .Sort
      .SetRange Range("Tawnton_data")
      .Header = xlGuess
      .Orientation = xlTopToBottom
      .Apply

Ron

PS sorry for spelling errors in Subject - unable to edit it.
 
Last edited:
Even changing the properties of the Arrow and sorting via menus, the arrow still doesn't move.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I changed the header OK but what does that mean?
The range per your code to be sorted does not include a header

Dim what is that ?
Declaration of a variable

where does your code actually fit into the current Tawnton code ?
Immediately before ThisWorkbook.Save
 
Upvote 0
I changed the arrow properties back to move with cells & they move but of course they reduced in size as the row height shrunk. so Move but don't size, yes they move but end up bewten roews. not actually point to the correct location. Once the shrunk row height is restored to 30, all is good
 
Upvote 0
OK, I added your code where you said & it fails at the .Apply in my code
Code:
 With Worksheets("Tawnton")
       .Sort.SortFields.Clear
   .Sort.SortFields.Add Key:=Range("Tawnton_time"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  With .Sort
    .Header = xlNo
      .Orientation = xlTopToBottom
     .Apply
'      Application.Goto Reference:="Tawnton_home"
'     Application.Goto Reference:="Charde_home"
      End With
      End With
      ThisWorkbook.Save

I commented the 2 Application.GoTo lines out

Now trying to step thru the macro in edit mode, it looses me, as I expect to see the range selected & highlighted and the various input boxes being set up & acted on. that is each VBA line, I want see it happening on the screen.
 
Upvote 0
This line has gone missing from your code :
Code:
        .SetRange Range("Tawnton_data")
 
Upvote 0
Thanks I don't how that vanished but it now comes up with this error for each cel line, it stops at
Code:
ith Worksheets("Tawnton")
    Range("Tawnton_data").RowHeight = 16.25
    For Each cel In Intersect(Range("Tawnton_data"), [E:E])
        If Left(Trim(cel), 3) = "Set" Then cel.RowHeight = 30
    Next

and how can I see it performing the various actions on the spreadsheet when I step thru the macro?
 
Upvote 0
What error are you getting and on what line?
It is working for me without any problem.
 
Upvote 0
It stops here and the error box has it " The item with the specified name wasn't found" but not being able to see it working on the page, I am guessing
I copied your coding straight into my file
Code:
For Each cel In Intersect(Range("Tawnton_data"), [E:E])
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,691
Members
449,117
Latest member
Aaagu

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