11-11-21 11:14 AM
Dim strDir as String = direction.Trim().Substring(0,1).ToUpper()Dim excel as Object = GetInstance(handle)Dim dirn as Integer = 0Select Case strDirCase "U"dirn = -4162 ' Excel.XlDirection.xlToUpCase "D"dirn = -4121 ' Excel.XlDirection.xlToDownCase "L"dirn = -4159 ' Excel.XlDirection.xlToLeftCase "R"dirn = -4161 ' Excel.XlDirection.xlToRightCase ElseThrow New ArgumentException("Invalid Direction: " & strDir)End SelectDim cell as Object = excel.ActiveCellWhile TrueDim nextCell as Object = GetNextCell(cell, strDir)If cell.Address = nextCell.Address Thencellref = ""ReturnElseIf cstr(nextCell.Value) = value Then ' We've found our blankcellref = nextCell.Address(False,False)ReturnEnd Ifcell = nextCellEnd While11-11-21 02:49 PM
11-11-21 09:01 PM
If you want to indicate all the lines having any specific value in a collection, in that case I have modified the code in such a way that you need to provide the following inputs & outputs:Dim strDir as String = direction.Trim().Substring(0,1).ToUpper()Dim excel as Object = GetInstance(handle)Dim dirn as Integer = 0Select Case strDirCase "U"dirn = -4162 ' Excel.XlDirection.xlToUpCase "D"dirn = -4121 ' Excel.XlDirection.xlToDownCase "L"dirn = -4159 ' Excel.XlDirection.xlToLeftCase "R"dirn = -4161 ' Excel.XlDirection.xlToRightCase ElseThrow New ArgumentException("Invalid Direction: " & strDir)End SelectDim totalRows As Integer = GetWorksheet(handle,workbookname,worksheetname).Cells.Find("*", , , , , 2).RowDim lineCount As Integer = 1excel.ActiveSheet.Range(cellref,cellref).Activate()Dim cell as Object = excel.ActiveCellDim temp As New DataTabletemp.Columns.Add("lineNo", GetType(Integer))For i As Integer = 0 To totalRowsDim nextCell as Object = GetNextCell(cell, strDir)If nextCell.Value = value Then ' We've found our valuetemp.Rows.Add(lineCount)End Ifcell = nextCelllineCount +=1Nextlines=temp
12-11-21 09:45 AM
12-11-21 09:48 AM
12-11-21 10:20 AM
14-11-21 03:27 PM