Jason Bayldon - 1 year ago 83

Vb.net Question

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?

Answer Source

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)`