Error sorting in Excel

I'm attempting to sort seven columns in Excel - Columns C through H. I have multiple headings with the data to be sorted starting in row 7. So I'm sorting on C7 through H7 with headings. Column D7 is the key to be sorted on.
Columns A and B and rows 1 and 2 are used by a program called Jet Reports which has already run before the sort routine.
That is why I'm selecting C3 instead of A1 as the starting point.

I get an error message on this line:
.ActiveCell.Offset(2, 0).Range("C3").Select()

Error message:
An unhandled exception of type 'System.MissingMemberException' occurred in microsoft.visualbasic.dll

Additional information: Public member 'ActiveCell' on type 'Worksheet' not found.

Here is the code adapted from code that works in VBA:
Dim XLApp As Object
XLApp = New Excel.Application
XLApp.Visible = True
XLApp.Interactive = True
With XLApp.Application.Worksheets("Report")

.ActiveCell.Offset(2, 0).Range("C3").Select() 'This line causes error
.Selection.Sort(key1:=.Range("D7"), order1:=.xlAscending, Header:= _
.xlYes, OrderCustom:=1, MatchCase:=False)
.Range("C7").Select() ' Returning home
End With

Are there any suggestions on how to correct the error or another way to do the sort?


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!