Re: Sorting excel in VB.net
you can define a Range in Excel like this
xlSt is your Worksheet
Code:
'....
'search in Column A
'Dim rngSearchValue As Range = xlSt.Range("A:A")
'or in Columns A to E
Dim rngSearchValue As Range = xlSt.Range("A:E")
'......
or use OLEDB with Sql which is easier IMO
Re: Sorting excel in VB.net
I understand that ChrisE but that isn't what I'm trying to do. I build the sort range based on what is before it on the spreadsheet so I don't know how many rows are involved until this point. The problem is that this is almost an exact copy of a sample that I was copying but it doesn't work because of the error I noted. Don't understand the error and why.
Re: Sorting excel in VB.net
Quote:
Also, the continuation underscore keeps disappearing when I put it in.
That is the nature of Visual Studio now.
Re: Sorting excel in VB.net
Quote:
Originally Posted by
JimReid
I understand that ChrisE but that isn't what I'm trying to do. I build the sort range based on what is before it on the spreadsheet so I don't know how many rows are involved until this point. The problem is that this is almost an exact copy of a sample that I was copying but it doesn't work because of the error I noted. Don't understand the error and why.
it is irrelevant how many rows there are if you create the range like I pointed out.
what does your Sheet look like and what is to happen with the filtered/sorted Data ?
display in a Datagridview perhaps?
Re: Sorting excel in VB.net
ChrisE,
It is important the number of rows. I have 1000+ rows before the group I want to sort. This is why I build a range from 10?? to 11?? for the range of rows. The answer to my question was in the Key1 field. It should have been xlWs.range and not what I had.