ManvinderKaur
Board Regular
- Joined
- Jun 16, 2010
- Messages
- 149
Hi I have four sheets
Baseline, reassessment, comparision and summary
I sort baseline as well as reassessment each time all sheets activate I am using following code
each time I activate sheet. That took 1 min to load. Is their anything wrong in code or it is always slow. I have 200 rows in baseline and reass. I have first four lines as header lines.
your help whould be greatly appreciated
Baseline, reassessment, comparision and summary
I sort baseline as well as reassessment each time all sheets activate I am using following code
Code:
Public Sub BaselineSortAsc()
Dim LastRow As Long 'This is the LAST Non Empty Row
Dim LastRowCount As Long
With Sheets("Baseline")
.Unprotect
LastRow = .Range("A" & Rows.count).End(xlUp).Row 'This is the LAST Non Empty Row
For LastRowCount = 4 To LastRow
.Range("A" & LastRowCount).Value = Trim(.Range("A" & LastRowCount).Value)
Next
.Range("A3:AZ" & LastRow).Sort Key1:=.Range("A3"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.Protect
End With
End Sub
Public Sub ReassessmentSortAsc()
Dim LastRow As Long 'This is the LAST Non Empty Row
Dim LastRowCount As Long
With Sheets("Re-assessment")
.Unprotect
LastRow = .Range("A" & Rows.count).End(xlUp).Row 'This is the LAST Non Empty Row
For LastRowCount = 4 To LastRow
.Range("A" & LastRowCount).Value = Trim(.Range("A" & LastRowCount).Value)
Next
.Range("A3:AZ" & LastRow).Sort Key1:=.Range("A3"), Order1:=xlAscending, Key2:=.Range("F3"), Order2:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
.Protect
End With
End Sub
your help whould be greatly appreciated