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()
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,627 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,642 questions
0 comments No comments
{count} votes