Jason Bayldon Jason Bayldon - 5 months ago 30
Vb.net Question

finding last row in excel and using excel.range

I am attempting to use a reference to interop.excel instead of vba to do some worksheet formatting. My code looks like:

Dim lastrow As Range = excel.Rows.End(XlDirection.xlDown)
Dim findme As Range = excel.Range("A1:A" & lastrow)

the excel.range does not allow me to use the "&" symbol here. How should I identify my last row of data?


Looking at the Range Class Reference, it seems you just missed to put the Row property of the lastrow Range:

Dim findme As Range = excel.Range("A1:A" & lastrow.row)