INSERT ROW

G

Guest

Guest
I have the following macro: RowNum = Application.InputBox(Prompt:="Number you want to insert ?", Type:=1)
Rows(RowNum).EntireRow.Insert
Rows(RowNum).Select
RowNum = Application.InputBox(Prompt:="What is the name ?", Type:=2)
End If
Range("A16") = InputBox("Input text to go in A16")

My question: In this case I have insert row 16,but what if this is 25.Do I have to change everytime this macro with Range("A25")
Can this not be variable.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I can think of a couple ways to do it. One way is after the "end if" type:
Range("A1").Select
For i = 1 to (RowNum-1)
ActiveCell.Offset(1, 0).Range("A1").Select
Next i
ActiveCell.Value = InputBox("Input text to go in A" & RowNum)

Of course, you'll have to put in "Dim i as integer" at the top of your subroutine.
 
Upvote 0
On 2002-03-13 12:45, tk19 wrote:
I can think of a couple ways to do it. One way is after the "end if" type:
Range("A1").Select
For i = 1 to (RowNum-1)
ActiveCell.Offset(1, 0).Range("A1").Select
Next i
ActiveCell.Value = InputBox("Input text to go in A" & RowNum)

Of course, you'll have to put in "Dim i as integer" at the top of your subroutine.
 
Upvote 0
On 2002-03-13 12:45, tk19 wrote:
I can think of a couple ways to do it. One way is after the "end if" type:
Range("A1").Select
For i = 1 to (RowNum-1)
ActiveCell.Offset(1, 0).Range("A1").Select
Next i
ActiveCell.Value = InputBox("Input text to go in A" & RowNum)

Of course, you'll have to put in "Dim i as integer" at the top of your subroutine.

Thanks for your answer.I have changed the
ActiveCell.Value in ActiveCell.Text
Is there a possibility that I get a message when I give a number in place of a text.
Example : "This is not the right text"
Many thanks
 
Upvote 0

Forum statistics

Threads
1,213,549
Messages
6,114,261
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top