How do you find the indent level of an excel cell?

I am looking at a file with several different cell indents. How do I determine the indent level of each using UiPath?

Hi @DavidV,

Have you tried look up in excel activity?

Do you mean the LookUp Range activity? If so, what would be the “Value to be searched”?

@ermanoj3101

Hi @DavidV ,

Can you share how your excel looks and which cell address you want to get ?

@ermanoj3101

image

This is the general idea. I would like to look through all of column A and determine the different indent levels for each cell. If you could help me figure out how to find the indent level for one, then I can figure out how to do that rest.

Who even builds Excels like this…

If the indent has been created with this thingy here
image

it’s probably not that easy. If it’s done with spaces however, you could simply read the range and count the leading spaces :smiley:

But I’ll accept the challange… will probably take the VBA route.

@T0Bi

Yeah it isn’t the easiest haha, and thanks for taking a look! It is from a report that gets generated. I’m guess in the code they have it auto-indenting base on category and subcategory, I can see the indent levels in the format cell section under alignment. My goal is to only grab the ones with a 0 indent level, so the “a” in my example above. I think I found a way to potentially to do part of it with VBA, but it would require me writing a value to the sheet then reading it back off (not the most ideal scenario). If there were a way to return the value per individual row to Uipath that would be helpful. If you have any questions, feel free to ask.
image
image
image

Here’s probably the easiest way

Create a .bas file with the following VBA

Function GetIndent(rg As String) As Long
    GetIndent = range(rg).IndentLevel
End Function

(cannot upload it because .bas files are not allowed)

Then use invoke VBA within your Excel Application Scope:

image

And call your getIdent.bas File and the function name “getIndent”.

As EntryMethodParameters you have to pass an Array (or any other IEnumerable) with the range like so:

image

The output variable will then contain the indent of your selected cell.

You can easily expand this with either an UiPath For Each loop or (even better) use the VBA code to go through all cells in a range and return all indents in an array.

If this has helped you, please mark this answer as the solution.

Hi @DavidV

Hope this xaml would help you resolve this
PRO-2.zip (8.7 KB)

Cheers

1 Like

@Palaniyappan

I think you may be using a more update version than me, as I am unable to view the activities, could you provide screen shots or a downgraded version? Currently using 2019.10.3

1 Like

no worries,

open the xaml file in studio
go to manage packages

downgrade the default packages to the version you have in any of your already existing xaml files

or

delete the Project.Json File in that folder and open the xaml

or

Cheers @DavidV

Hi @DavidV

Is the xaml provided working fine
Are we facing any issue in accessing that file

@Palaniyappan

Yes, I am still unable to open the file, although, I am sure that it would work correctly. I also didn’t have a lot of success duplicating it. Currently I have a modified version of some of the VBA that was discussed earlier.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.