In Excel Worksheets("Sheet1").Cells(Rows.count, 1).end(xlup).row will give me the last row in column "A".
What is it in VB.net?
Sub LastRow()
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
xlApp = GetObject("", "Excel.Application")
xlApp.DisplayAlerts = False
xlBook = xlApp.Workbooks.Open("C:\mypath\File1.xlsm")
xlSheet = xlBook.Worksheets("2013")
xlSheet.Activate()
With xlSheet
For k = 1 To .Cells(Rows.count, 1).end(xlup).row
'code
Next k
End With
xlApp.DisplayAlerts = True
xlBook.Close()
xlApp.UserControl = True
xlApp.Quit()
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
End Sub
What is it in VB.net?
Sub LastRow()
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
xlApp = GetObject("", "Excel.Application")
xlApp.DisplayAlerts = False
xlBook = xlApp.Workbooks.Open("C:\mypath\File1.xlsm")
xlSheet = xlBook.Worksheets("2013")
xlSheet.Activate()
With xlSheet
For k = 1 To .Cells(Rows.count, 1).end(xlup).row
'code
Next k
End With
xlApp.DisplayAlerts = True
xlBook.Close()
xlApp.UserControl = True
xlApp.Quit()
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
End Sub