Looping a command in Visual Basic


Posted by Nikolas Green on August 18, 1999 7:36 AM

I am using a large database worth of information. I download it into Excel without any problem. I want to input the information into a worksheet that I am using. The problem is that the worksheet has merged cells in it. When I go to paste from the database info. I have to paste one cell at a time. I want to create a little program that will insert five rows between each item in the database. I know that I could record a macro that will result in me having to insert the rows myself. I would like to loop the program so that it runs forever, or until I make it stop. I want the program to insert the five rows then advance down to the next item and insert the rows etc... How do I loop a command in Visual Basic.



Posted by Chris on August 18, 1999 12:03 PM

Give this a shot.

Sub adsf()
Do Until ActiveCell = ""
Range(ActiveCell, ActiveCell.Offset(4, 0)).EntireRow.Insert Shift:=xlDown
ActiveCell.Offset(6, 0).Select
Loop
End Sub

It will loop until there is a blank row.

Chris