Create Table in Excel Worksheet using VBA

I need to execute following code using invoke code activity. Someone, please guide me.

Sub DynamicRange()
'Best used when first column has value on last row and first row has a value in the last column

Dim sht As Worksheet
Dim LastRow As Long
Dim LastColumn As Long
Dim StartCell As Range

Set sht = Worksheets("Sheet1")
Set StartCell = Range("D9")

'Find Last Row and Column
  LastRow = sht.Cells(sht.Rows.Count, StartCell.Column).End(xlUp).Row
  LastColumn = sht.Cells(StartCell.Row, sht.Columns.Count).End(xlToLeft).Column

'Select Range
  sht.Range(StartCell, sht.Cells(LastRow, LastColumn)).Select

End Sub

I found the solution by using Invoke VBS :smiley:

1 Like

Is “Invoke VBS” an UiPath activity? Cant find it. Do we need any package to be installed for this? Please assist.

1 Like

@vvaidya Thank you for the quick response…

Update the Excel activity package