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:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Do you mean you want the row heights to follow the sorted values or to remain where they are?
If you want them to follow but they are not, then would adding code to autofit the rows after sorting provide what you need?
 
Upvote 0
Yes, I want all formatting of the row to follow the data including a drawing of an arrow in some rows.

The bigger row is not based on Autofit but a specific size

not sure how to attached the spreadsheet file

Ron
 
Upvote 0
How many rows have special heights?
Is there a way of identifying such rows (e.g. particular text in one of the columns)?
I cannot think of a non-VBA way of doing what you want.
 
Upvote 0
OK, can't attach files ,

You can upload your sample workbook (without classified data) somewhere (maybe to dropbox.com or google drive) then post the link here.
 
Upvote 0
How many rows have special heights?
Is there a way of identifying such rows (e.g. particular text in one of the columns)?
I cannot think of a non-VBA way of doing what you want.

The number or rows varies and in different positions depending on which spreadsheet - i have 12 variations of the spreadsheet
Yes, the larger rows have the words Set up as part of the cell info
but not only are those rows affected but I do have qn image of an arrow in two other rows - one is standard height and the other is the larger height 30 as compared to 16.1




Uploading files- I don't use Dropbox or Google drive but I will see about Dropbox.

Ron
 
Upvote 0
Change this line in your sort codes :
Code:
.Header = xlGuess
to this :
Code:
.Header = xlNo

Change the properties for your arrows to : Move but don't size with cells

Add this after the Tawnton sort code :
Code:
Dim cel As Range
With 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
End With
 
Upvote 0
I understand some of that but I am just coming to grips with VBA

I changed the header OK but what does that mean?

so the first line of the new code
Dim what is that ?

and where does your code actually fit into the current Tawnton 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
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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