I would like to convert this VBA code in C#
Can anyone please help.
VB.NET
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
ketan borsdiyaRank #2,258 · 624 reputationPosted Jul 6, 2016, 12:55 AM EDT
Suvendu Shekhar GiriRank #546 · 4.4K reputationPosted Jul 5, 2016, 10:42 PM EDT
Francis SusaimichaelRank #466 · 5.4K reputationPosted Jul 5, 2016, 10:46 PM EDT
Guest User20 reputationPosted Jul 6, 2016, 12:05 AM EDT
long LColumn = 0;
xlWorkSheet.Activate();
int dataCount = (int)xlApp.WorksheetFunction.CountA(xlWorkSheet.Cells);
if (dataCount == 0)
{
// All cells on the worksheet are empty.
}
else
{
// There is at least one cell on the worksheet that has non-empty contents.
{
Lrow = xlWorkSheet.Cells.Find(What: "*", After: xlWorkSheet.Cells[1, 1], SearchOrder: xlByRows, SearchDirection: xlPrevious).Row;
LColumn = xlWorkSheet.Cells.Find(What: "*", After: xlWorkSheet.Cells[1, 1], SearchOrder: xlByColumns, SearchDirection: xlPrevious).Column;
}
}
Guest User20 reputationPosted Jul 6, 2016, 1:25 AM EDT