I have a code. I can use this formula without using sheetname for lookup.
Dim xlApp As Microsoft.Office.Interop.Excel.Application = New Microsoft.Office.Interop.Excel.ApplicationClass
Try
Dim xlWorkbook As Microsoft.Office.Interop.Excel.Workbook = xlApp.Workbooks.Open(Path)
Dim xlWorksheet As Microsoft.Office.Interop.Excel.Worksheet
xlWorksheet = CType(xlWorkbook.Sheets(sheetName),Microsoft.Office.Interop.Excel.Worksheet)
xlWorksheet.Activate()
Dim RowsCount As Int32 = xlWorksheet.UsedRange.Rows.Count
xlWorksheet.Range(Range+RowsCount.ToString).Formula=ExcelFormula
xlWorkbook.Save
xlWorkbook.Close
Catch ex As Exception
Throw ex
Finally
xlApp.Quit
End Try
Hi @Anil_G , thank you for response. But it gives me an error:
21.10.6+Branch.support-v21.10.Sha.5cb5747f95eaecc8ba6a6256e82fd4d128d2c90e Source: Invoke code: VLOOKUP Message: Exception has been thrown by the target of an invocation. Exception Type: System.Reflection.TargetInvocationException RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC at UiPathCodeRunner_8fcefede64c443379efca47c0e334146.Run(String sheetName, String Path, String ExcelFormula, String Range) — End of inner exception stack trace — at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams) at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object args) at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List1 inArgs, IEnumerable1 imps, Object args) at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)— End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at UiPath.Executor.BaseRunner.EndExecute(IAsyncResult result) at UiPath.Executor.InProcessRunner.EndExecute(IAsyncResult result) at UiPath.Core.Activities.ExecutorInvokeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result) at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result) at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)