Textbox with insert Rows in Excel 2000 VBA

L

Larry D

I am working on some code with Excel 2000 VBA and Microsoft
Windows 2000.

I want to do a textbox prompt, get a number and insert the
amount of rows that the user selects.

Here's what I have, but it only inserts one line, no matter
how many rows the user tells it:

' code starts here
Dim answer, counter as integer
inputbox "How many rows would you like to insert?", answer

For counter = 0 to answer
activecell.entirerow.insert
next counter
' code ends here
 
J

Jim Cone

Sub GiveMeMore()
Dim strAnswer As String
Dim counter As Integer
strAnswer = InputBox("How many rows would you like to insert?", "How Many", 1)
If Len(strAnswer) > 0 Then
If Val(strAnswer) > 0 Then
For counter = 1 To Val(strAnswer)
ActiveCell.EntireRow.Insert
Next 'counter
End If
End If
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Larry D" <[email protected]>
wrote in message
I am working on some code with Excel 2000 VBA and Microsoft
Windows 2000.
I want to do a textbox prompt, get a number and insert the
amount of rows that the user selects.
Here's what I have, but it only inserts one line, no matter
how many rows the user tells it:

' code starts here
Dim answer, counter as integer
inputbox "How many rows would you like to insert?", answer

For counter = 0 to answer
activecell.entirerow.insert
next counter
' code ends here
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top