4,375 questions
VSTO VB.net sort by second column without excluding first column
Jonathan Brotto
1,076
Reputation points
I would like to sort by the second column, but it seems it skips my first column. Is there a way around that?
'added C code to newer version of report Merge the 2
customerRng = Globals.ThisAddIn.Application.Sheets("Customer Summary").Range("A:B")
rawRng = Globals.ThisAddIn.Application.Sheets("Raw SAP").Range("D:E")
rawRng.Copy(customerRng)
customerRng.RemoveDuplicates(1, Microsoft.Office.Interop.Excel.XlYesNoGuess.xlGuess)
customerRng = Globals.ThisAddIn.Application.Sheets("Customer Summary").Range("B:B")
customerRng.Sort(
Key1:=customerRng.Columns(1), Order1:=Excel.XlSortOrder.xlAscending,
Key2:=customerRng.Columns(1), Order2:=Excel.XlSortOrder.xlAscending,
Orientation:=Excel.XlSortOrientation.xlSortColumns,
Header:=Excel.XlYesNoGuess.xlYes,
SortMethod:=Excel.XlSortMethod.xlPinYin,
DataOption1:=Excel.XlSortDataOption.xlSortNormal,
DataOption2:=Excel.XlSortDataOption.xlSortNormal,
DataOption3:=Excel.XlSortDataOption.xlSortNormal)
customerRng.EntireColumn.AutoFit()
Microsoft 365 and Office Development Other
Developer technologies VB
2,892 questions
Sign in to answer