Beginner1200
New Member
- Joined
- Jan 18, 2023
- Messages
- 16
- Office Version
- 2019
- Platform
- Windows
My code I have been woorking on
My idea is to get the code. Sort until last row with data, but then go one up and leave the last row alone. And all the rest from A5 until last row -1 with data should be sorting But only to sort the first 6 letters. ex Even if in range("A5:A15") one is ex "105.00" and "185.00; Like" in the range ("A5:A15") It has to sort only the first 6 letters.
My idea is to get the code. Sort until last row with data, but then go one up and leave the last row alone. And all the rest from A5 until last row -1 with data should be sorting But only to sort the first 6 letters. ex Even if in range("A5:A15") one is ex "105.00" and "185.00; Like" in the range ("A5:A15") It has to sort only the first 6 letters.
VBA Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Left(Range("B4"), 6, Left(Range("B"), 6 & Rows.Count).End(xlUp).Offset(-1)).Sort Key1:=Range("B4"), Order1:=xlAscending, Header:=xlYes
End Sub