VSTO VB.net sort by second column without excluding first column

Jonathan Brotto 1,076 Reputation points
2022-03-03T16:52:31.733+00:00

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
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.