Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I m trying to expand the rows of a excel sheet automatically, but unable to do so.

Please tell me how to do.

Below is the code i tried.

What I have tried:

obj_Range = objxlApp.get_Range(objxlApp.Cells[(i + 2), 1], objxlApp.Cells[(i + 2), dataTable.Columns.Count]);
obj_Range.Font.Bold = true;
obj_Range.Font.Size = 12;
obj_Range.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White);
obj_Range.Cells.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.SteelBlue);
obj_Range.EntireRow.AutoFit();
obj_Range.Rows.AutoFit();
Posted
Updated 24-Mar-16 1:30am

1 solution

The easiest way to to it is run Excel, load a sheet and record a macro executing the steps you want to replicate, stop recording, open Visual Basic and look at the recorded Macro.

Recorded macro to autofit column A:

Columns("A:A").EntireColumn.AutoFit

You may need something like obj_Range.Columns.EntireColumn.AutoFit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900