Separation of data from sheet 1 base on the bill code separate into sheets

Hi ,

Pleas help since I am encountering an error when my flow proceed to 2nd readrange, but before that here is my flow

I have readrange at the beginning of my xaml
I have save it as dt_masterlist

For each row in datatable
Datatable = dt_masterlist
Itemname = CurrentRow

In Body I have assign activity ,
sheetName = CurrentRow(“Bill Code”).ToString.Trim

Then I invoke my creationofsheet.xaml
In the invoke arguments i have

in_sheetName = sheetName
in_Template = “Sheet1”
in_Range = “A1”
in_fileName = filepath

Then after invoke workflow
I have another readrange workbook output is dt_result
Workbook path = filepath
Sheet Name = sheetName
Range = “A1”

On my debug
There has value for sheetName but I am encountering an error

Range workbook: Object not set to an instance of an object
And my dt_result is null.

1 Like

Hi,
Did you try Log Message the filePath and the sheetName just before the second read range activity?

Hello

The “Object not set to an instance of an object” error when reading an Excel workbook often means the file or the worksheet cannot be found or accessed.

Since the error happens inside the loop on the second Read Range, perhaps this is the problem.

The most common causes are related to timing and file access:

  1. File Lock: Your creationofsheet.xaml likely opens the Excel file (filepath). Maybe the problem is that the invoked workflow is not closing the file quickly or correctly, leaving it locked when the second Read Range tries to access it.
  2. Sheet Existence: While sheetName has a value, perhaps the sheet does not exist in the workbook at that exact moment. The name might be slightly different, or the invoked workflow failed to create it properly.

You could try adding a small delay (1-2 seconds) before the second Read Range Workbook activity. This gives the file time to close and release the lock.

Try these checks, and maybe it will work!