Splifford1
New Member
- Joined
- Jun 30, 2018
- Messages
- 6
Hi!
I set up the code (pasted below) to sort a product list but if I add a blank space in the column between names it will not sort any cell after the first blank cell in the column!How can I make the code to sort everything from A2:B1000?
This is causing that my combobox which extracts the info from the a 'name manager' product list to not have all of the names that appear below the first blank cell.
A1 and B1 are headers
A2 and B2 all the way to A1000 AND B1000 is the list designed space.
I set up the code (pasted below) to sort a product list but if I add a blank space in the column between names it will not sort any cell after the first blank cell in the column!How can I make the code to sort everything from A2:B1000?
This is causing that my combobox which extracts the info from the a 'name manager' product list to not have all of the names that appear below the first blank cell.
A1 and B1 are headers
A2 and B2 all the way to A1000 AND B1000 is the list designed space.
Code:
Sub GOBACKTOMENUFROMPRODUCTDB()Application.ScreenUpdating = False
Application.Calculation = xlManual
Hoja5.Unprotect Password:="...."
[B] Set rng2 = Sheet5.Range("A2:A1000")[/B]
[B] With Sheet5.Sort[/B]
[B] .SortFields.Clear[/B]
[B] .SortFields.Add Key:=rng2, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal[/B]
[B] .SetRange Hoja5.Range("A1").CurrentRegion[/B]
[B] .Header = xlYes[/B]
[B] .MatchCase = False[/B]
[B] .Orientation = xlTopToBottom[/B]
[B] .SortMethod = xlPinYin[/B]
[B] .Apply[/B]
[B] End With[/B]
'THE CODE BELOW IS JUST TO COPY THE BASIC EXCEL CELL FORMAT FROM A HIDDEN CELL TO THE LIST ITEMS TO MAKE IT STANDARDIZED.
''
Range("S3").Select
Selection.Copy
Range("A2:A1000").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("T3").Select
Selection.Copy
Range("B2:B1000").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
'''''
Sheet7.Visible = True
ActiveSheet.Visible = False
Sheet7.Select
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
Sheet5.Protect Password:="....", AllowSorting:=True, AllowFiltering:=True
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub