Textbox with insert Rows in Excel 2000 VBA

  • Thread starter Thread starter Larry D
  • Start date Start date
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
 
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
 
Back
Top