Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VISUAL BASIC FOR APPLICATION (EXCEL) -- INSERT ROWS

Status
Not open for further replies.

marboa62

Technical User
Jul 4, 2008
9
IT
good morning America !

I have a little program in visual basic for application in Excel

The code "Selection.EntireRow.Insert" allow to insert only one row in the sheet

How can I insert 100 rows one-shot ?

Thank you

Marins
 
It's also a good morning in the UK.

By the way, typing your subject title in ALL UPPER CASE is considered the same as shouting ... please don't do it.

As for your query, about VBA ( see forum707 for VBA queries ), your code is inserting however many rows are covered by your Selection. If it was 100 rows it would insert 100 rows. I tend to not use Selection or selecting of objects in macro code so as to speed up and tidy up code. For example:
Code:
Range("A5:A105").EntireRow.Insert

Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
Thanks Glenn,

I promise non to use caps in the title in the future, I knew that but I didnt' give a format in the hurry

So I can use Range ...

My complete code is
...
Range("B2").Select
Selection.End(xlDown).Select
For y = 1 To 100
Selection.EntireRow.Insert
Next y
...
You can see I need insert 100 rows in a dynamical position (End(xlDown)

Range ("A5:A105") does not work

Perhaps can I use Cells ?

have a nice day

Marins


 
In what way does Range ("A5:A105") not work? How are you using it exactly? Do you get an error message, or does it do something that you didn't expect?

Your code appears to reduce to something like this:
Code:
Range("B2").End(xlDown).Resize(100).EntireRow.Insert

Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
Great Glenn !

Thank you so much !

Hasta luego

Marins

I may be wrong but I have no doubt
 
My pleasure! :-D

Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top