cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Workbook Formula

RajathGopal
Level 5
Hello, Is there a way to add formula for the entire column using BP.  Suppose I have 50 records in a column and the formula is already applied and after some calculations if the records increases to 60 from 50 the formula wont be applied to the new 10 records. Is there any way to achieve this? or apply formula for the new rows that has been added? Thanks in advance.
3 REPLIES 3

Mustafa_UlasYig
Level 6
Hi Rajath.Gopal As I see it, your only option is to go to the next empty cell and paste the formula to ALL of the cells below this next empty cell. Of course this is only a solution if there are no rows with information below where you are pasting the formula. If yes, then I have a suggestion for a solution. But in order to do this, you need to send Global Send Keys and Key events. Therefore, you have to create an Excel BO that opens C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE (or whatever version of excel you have) and launches and attaches to your excel workbook with this BO. 1) Use MS Excel VBO action ""Attach To Workbook"" to get the handle of the Excel workbook. Use this handle as input to MS Excel VBO action ""Go To Next Empty Cell Down"" to get the cell-reference of the next empty cell/line on the worksheet in your workbook. 2) Create an Excel BO and create a page that has 1 navigate stage with 3 actions: a) Use the action ""Global Send Key Event"" with the application root element, and input Text = ""{CTRL}"" to send Shift + Ctrl + down arrow, this selects the entire rows in the worksheet from the cell-reference and down. Make sure that you are in the cell-reference that you found in 1), when using the navigate stage. A good idea could be to pass this as input to and use it in your Excel BO, if somehow you should end up in another cell, when switching between the 2 BO's. b) Use the action ""Global Send Keys"" with the application root element, and input your formula in input Text e.g ""=3*3"". c) Use the action ""Global Send Key Event"" with the application root element, and input Text = ""{CTRL}"" to send Ctrl + Enter, so that the formula is copied to the cells from cell-reference and down. Set ""Pause After Each Step to 0,1. Then you simply re-attach to the MS Excel VBO again and carry on with your business. Good luck, let me know if you have any questions. BR, Mustafa

RajathGopal
Level 5
Thank You so much Mustafa will let you know if I come across some issue.   However I have a question, do we have any other way to send formula to the entire column without using Send Keys ?

AndreyKudinov
Level 10
You can do it without sendkeys in two ways: using excel macro or in custom code stage.  You'll have to add new action to excel vbo for the second one, make a copy of it. You'll end up doing that sooner or later anyway.   You should still know your last row or you'll have to find it first too. There are many way finding last row (in order of how this is used in my custom action): 1) .UsedRange - this can go wrong sometimes, when it comes back as A:Z (whole columns). Default VBO uses that and fails due to this in several places.  2) .CurrentRegion - fails on protected sheets :((  3) Using .Cells(1).Find ""*"", backwards, byrows Looping manually through the column is also an option, but can take ages.