Delete/Insert Row in Excel via Macro

rcl

New Member
Hello,

I want to delete or insert a row in excel. I wrote macros for both, and I have BP call the macros and pass in arguments. Can anybody tell me why nothing happens when I call these macros? I believe my syntax is correct, and I'm having success passing in arguments from BP to another macro I made, but both delete and insert rows don't do anything when called. BP will step through without any issues - no error messages - but nothing changes in excel.

I'm relatively new to BP and VBA, so there is room for error in my syntax, but I think it should be working. I can have BP call a macro to delete a specific row, i.e. hard-code the row in the VBA sub, but I'd rather be able to pass in my arguments dynamically from BP. By that I mean calling the hard-coded macros from BP works. Those will delete and/or add rows, but something is going wrong or missing when I try to run the dynamic macros -- passing in the row(s).

I know there will be any number of ways to accomplish deleting or inserting a row from BP, but before moving on to those, I'm curious as to what's going awry here. I'd like to be able to consistently script dynamic VBA macros to call from BP, so this is a good example to walk through.

Thanks
 

Attachments

  • Delete Rows (1).PNG
    22.4 KB · Views: 39
  • Delete Rows (2).PNG
    7.8 KB · Views: 27
  • Delete Rows (3).PNG
    3.8 KB · Views: 24
  • Insert Rows (1).PNG
    22.7 KB · Views: 28
  • Insert Rows (2).PNG
    26 KB · Views: 19
  • Insert Rows (3).PNG
    6.7 KB · Views: 17

gil.silva

Active Member
Hello rcl,

Thank you for such detailed explanation in showing the problem.
I won't focus on why the macro isn't working via BP, instead, I will advise you to adopt other solutions.

Blue Prism has code integration and if you give a look, all the actions developed in Excel VBO are code-based, using VB.net, which is very similar to VBA.
Therefore, you have 2 good solutions:
  • Duplicate one existent action from the Excel VBO and adapt to delete/add rows (the code is similar to the VBA that you created)
  • Use the existent actions from Excel VBO, you can use Select, Delete and Insert to accomplish the actions that you need.
So, I would avoid the use of macros, since BP can mimic the same execution.

Let me know if you have any questions.
 
Top