Jeet_Dhillon
New Member
- Joined
- Jul 13, 2019
- Messages
- 19
Friends , I am trying to Sort a Sheet but Cells are merged , i was able to record a Macro by Manually Unmerge Cells and then Merge , But this whole Process takes time and Lag.
Any Suggestions to Tune up this Code .
Thanks
"Private Sub Repairsort_Click()
RepairSort.BackColor = 9434879
Range("D30:Q64").Select
Selection.UnMerge
Range("B30:T64").Select
ActiveWorkbook.Worksheets("Forepersons Report").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Forepersons Report").Sort.SortFields.Add Key:= _
Range("B30"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Forepersons Report").Sort
.SetRange Range("B30:T64")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("D30:F64").Select
Selection.Merge True
Range("G30:Q64").Select
Selection.Merge True
Range("G47:Q47").Select
End Sub"
Any Suggestions to Tune up this Code .
Thanks
"Private Sub Repairsort_Click()
RepairSort.BackColor = 9434879
Range("D30:Q64").Select
Selection.UnMerge
Range("B30:T64").Select
ActiveWorkbook.Worksheets("Forepersons Report").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Forepersons Report").Sort.SortFields.Add Key:= _
Range("B30"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Forepersons Report").Sort
.SetRange Range("B30:T64")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("D30:F64").Select
Selection.Merge True
Range("G30:Q64").Select
Selection.Merge True
Range("G47:Q47").Select
End Sub"