Inserting Blank Rows & Merging Cells in Excel Using Interop Excel C#

24 Views Asked by At

I would Like to know how I would insert blank rows in an Excel Spreadsheet using Interop Excel, and also merging cells. A7 would be the row I would be starting from to insert the rows. The number of rows inserted would vary. I would intend on inserting the rows downward. after inserting the rows I would have to merge a few cells. I would have to merge cells from B7 to E7. Code examples appreciated & show Excel declarations as well please. All data in the rows will be strings types only no formulas or numbers.

Any help much appreciated.

1

There are 1 best solutions below

1
rotabor On
  1. Open an Excel workbook.
  2. Turn on "Record Macro" (Developer ribbon).
  3. Perform manually everything what you need to do.
  4. Stop macro recording.
  5. Open VBA editor and evaluate the recorded macro. You can correct something, improve.
  6. Run the corrected macro to verify it.
  7. Copy the code to your c# program and edit it to meet c# requirements.