Find the number columns in excell sheet

VJR

Well-Known Member
Try 'Set Cell' to set the formula as "=Column(AAE1)"
Then 'Get Cell' to get its value which will be 707.
 

VJR

Well-Known Member
Hi @nkumarkolla,

I might have misinterpreted your question. By the wordings "in AAE" I assumed it to be column AAE of Excel, but I think you may want to know how to find the the total number of columns in an Excel sheet and below are the commands in Automation Anywhere.

-Open Worskheet: Either New or existing

-Activate sheet: Activate the required sheet

- Go to cell: A1

-Insert keystrokes - Control and Right arrow

Here there are two options:
i. If the sheet contains data in the first row: then you need to Insert these keystrokes twice so that it will take you to the last column (or can set it to maximum no. of times if you do not know how the 1st row is)

ii. If the sheet does not contain any data then only once.

-Set cell: 'Set Cell' to insert the formula as "=Column()"
This will give the result as shown in the screenshot.

- Then you can either close the worksheet without saving Or just Set cell this cell back to blank so that the formula is removed.

This is Office 2010 so the last column number is 16384.

LastColumnNoExcel.JPG
 
Last edited:

NoSpaceForLove

New Member
Hello nkumarkolla,

I am able to resolve this issue with ( 2 excel files) one excel (with header) and with another excel( withour header). see below steps -->

step 1) define any 3 local variable like i = 1, j = 0, k = NULL

stpe 2) excel command - Open Excel ( Contains header - Yes, you can make it as No in your machine )

step 3) excel : Go to Cell A1

step 4) now here we need perform loop operation for count number like 1000 because we may not know how many columns in the provided excel sheet ( i have kept it as - 50 for me because i know there are only 10 columns in my excel sheet )

step 5) in loop - Get value of Active Cell ( A1 cell ) and assing this value to variable 'i'

step 6) in loop (Add if commend )- if command - check if 'i'<> 'k' ( as 'k' is null we defined earlier )
note: if 'i' variable( value of active cell) is not null then only below command will be executed , this will also ensure us that we are only considering only non-empty columns

step 7) in loop - (inside of ) if command - add 1 in variable 'j' ( this variable will hold the count of the columns of excel )

step 8) in loop - end if ( end of if command)

step 9) in loop - excel go to one cell right of active cell
note : this command will allow is to move to right cell ( next column ) of excel sheet

step 10) end of loop command

step 11) close the excel sheet

step 12) message box - variable 'j' which is the exact column count of excel sheet

if you found any correction please let me know.

warm regards,
NoSpaceForLove
 

ravi338

New Member
Hi,

You can directly know how many rows and columns for a excel file. Just follow the simple steps

1. Create one array variable (which is asking to browse your excel file to read the data (all data))
2.Take Message Box command. Call the system variable "array row" and "array column" over there

It will show the how many rows and columns available for a particular excel you browsed. I hope this can help.
 
Top