Division in Excel - DB Null error

Hi All,

Hope I am posting this under the right catergory. I would greatly appreciate assistance with the below please.

I need to take a column of values from excel cell F2. [150] in this case.
Multiply F2 by 100;
Divide the result by cell G2; [191]
Final answer to be placed in cell H2.

I used an assign statement as per below:

perMaxHR = Convert.ToInt32(row(5))*100/Convert.ToInt32(row(6))

But i keep getting an error: Object cannot be cast from DBNull to other types.
This only happens when i divide the result by cell G2.
If i divide the result by cell A1 for example then everything works fine. I would really apprecite your assistance. Thanks in advance.

Hi @Rinesh1,


CDbl is also Convert.ToDouble. Store the variables as Double.

Thanks @GreenTea,

I made the changes to the assign box and changed variables to “double” but its still complaining about the DBnull values.

Error: “Calc % of Maximum Heart Rate: Conversion from type ‘DBNull’ to type ‘Double’ is not valid.”
Assign box

error code

Hi @Rinesh1

I have made the workflow that is not giving any error and working fine too which was giving error in your case.

Below is the attached workflow for the same :-
MainPratik.xaml (9.9 KB)
Forum _ Rinesh.xlsx (9.6 KB)

Output :-

Mark as solution and like it :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @Pratik_Wavhal

Thank you for this, your time and effort is appreciated. I do indeed find that your flow works 100%.
I attempted to incorporate what you have done in my flow but still experience the DBNull error, from a learning perspective with it would be extremely valuable to know where I am going wrong.

Will it be possible to have a look at my flow to determine what could be the problem, I have attached my automation. Thank you in advance.
FromWord2Excel.xaml (26.2 KB)
Request.docx (12.5 KB)
Book1.xlsx (8.2 KB)

Hi @Rinesh1

I have debug the code in which i found that it is not retriving the row(“Max_Heart_Rate”).ToString value. So How can blank value get divide to some number.
image
image

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @Rinesh1

I have Updated the workflow.
Request.docx (12.5 KB)
Book1.xlsx (8.9 KB)
FromWord2Excel.xaml (28.7 KB)

Output :-

Mark as solution and like it :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @Pratik_Wavhal;

Thank you, suspected it was not reading that “Max_Heart_Rate” field but have no clue how to fix it. I am trying to open the XAML file you sent with the updated workflow but not able to to:(
Getting this error in Studio:

Error opening XAML

PS: I am writing values back to “Max_Heart_Rate” so it’s strange that it does not read it.

Hi @Rinesh1

Which activity is showing missing ??

I have not added any extra activity and already i have solved the issue.

Can you share the Screenshot of the workflow where it is showing missing

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

Hi @Pratik_Wavhal, I am not saying you removed anything. I can’t open your updated workflow in Studio. Gives me a message " This activity is either missing or could not be loaded properly" I am not sure what the issue is. See screen shot.

With regards to

hi @Rinesh1

Ok. I will show you the changes what i did in your workflow by SS so missing activity will not happen.
Ok ?

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hi @Rinesh1

The changes are as below

Hope this help you now. By this your workflow will work.

Mark as solution and like it :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@Pratik_Wavhal, It’s working well :grinning:, thank very much for taking the time to assist me. Its much appreciated.

Hi @Rinesh1

You are welcome :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

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