Dim Lrow,LColumn as Long
Sheet1.Activate
If WorksheetFunction.CountA(Cells) > 0 Then
LRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LColumn = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
End If
Can someone help to convert this vba code to C# getting lastrow and lastcolumn in a worksheet.
or Try this to get last row and last column of excel sheet,
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
// get the reference of first sheet. By default its name is Sheet1.
// store its reference to worksheet
worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item(1);
int rowcount = worksheet.Rows.Count;
int colcount = worksheet.Columns.Count;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.