How to check particular name sheet exist or not in 5 excels

Hi Everyone,
I have 5 manager excels with team member name sheets
I want to search team member sheet is exist or not and if exist go to that sheet
and read that sheet
can anyone help me out here, I am new to excel automation
@Palaniyappan
@Gangadhar_Athili
@supermanPunch

1 Like

Hi

You can use GET WORKBOOKSHEETS Activuty and get the list of sheet names as a List variable
Then use a IF condition like this to check whether the name u want is there in list variable or not

list_variable.Contains(“your name”)

Have a view on this for an example

https://docs.uipath.com/activities/other/latest/productivity/excel-get-workbook-sheets#example-of-using-the-get-workbook-sheets-activity

Cheers @panguluri_saritha

thank you @Palaniyappan but I want search in 5 dynamic excels like eg Team Manager Tracker Ganesh September.xlsx, in all these 5 excels we have to check that Ganesh sheet exist or not
Could you please you suggest the code
@Palaniyappan

Hi, upto Tracker its consistent, name and current month would be dynamic
@Palaniyappan

Fine

Use a assign activity like this

arr_files = Directory.GetFiles(“your file path”)

Where arr_files is a variable of type array of string

Now use a for each loop and pass this arr_files as input and change the type argument as string
Inside the loop you can follow the same step as mentioned above

Or

If u r trying with modern activities you can loop through all files in a folder with this activity

https://docs.uipath.com/activities/other/latest/workflow/for-each-file-x

Cheers @panguluri_saritha

@panguluri_saritha
assign
arr_files=directory.getfiles(“folderpath”)

arr_files is the array of string
use for each for excel files
2.inside use excel application scope inside use get workbook sheets
3.use if condition
booloutput=outputsheets.Any(Function(x) x.ToString.Equals(“sheetname”))

gives boolean value
in then block
use read range activity to read the sheet

cheers

@panguluri_saritha

Get workbook sheets activity(output : Collection of sheets) ,
after that verify if the collection contains particular sheets
Like, Col_Sheets.Contains(“InlutSheetName”)

If you want index,
Col_Sheets.Index(“InputSheetName”)

solution by @Gangadhar_Athili