Jason Bayldon Jason Bayldon - 1 year ago 119
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?

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)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download