ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,731
- Office Version
- 2007
- Platform
- Windows
I have recorded amacro to sort column E from A-Z
Row 1 are headers & value are row 2 then down the page.
The sort works fine BUT the recorded code is way to long so need to condense it.
Also noticed the range was still selected once sorted.
At the end of the recorded code i thought by adding to select cell A1 would work but i then get an error.
Please advise thanks
Row 1 are headers & value are row 2 then down the page.
The sort works fine BUT the recorded code is way to long so need to condense it.
Also noticed the range was still selected once sorted.
At the end of the recorded code i thought by adding to select cell A1 would work but i then get an error.
Please advise thanks
Rich (BB code):
Private Sub CommandButton3_Click()
Dim varNewValue As Variant
varNewValue = InputBox("Enter the desired value for Col. E:")
If Len(varNewValue) > 0 Then
ThisWorkbook.Sheets("DATABASE INFO").Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Value = varNewValue
End If
ActiveWorkbook.Worksheets("DATABASE INFO").ListObjects("Table5").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("DATABASE INFO").ListObjects("Table5").Sort. _
SortFields.Add Key:=Range("Table5[[#All],[CLONING MODEL]]"), SortOn:= _
xlSortOnValues, Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("DATABASE INFO").ListObjects("Table5").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
With ThisWorkbook.Worksheets("DATABASE INFO")
.Range("A1").Select
End With
End Sub