Input VBA

H

Having A Hard Time

Hi,

I am having a very had time making this work. I was given
a modification to some code I have that will allow an
inout box to appear asking for a value but the code will
not copy the rows and formulas as I need them...Can
someone please help me make this work? I am trying to get
it to display the input box, then after a value is put in
there, the rows and formulas will be copied to the next
row...This modification does accept the input but it
inserts a blank row then a row with the copied formulas
instaed of however many rows stated with the formulas also
copied and no blanks...

Sub insertrowswithformulas()
nrows = InputBox("How many rows")
ActiveCell.Resize(nrows, 1).EntireRow.Insert
With ActiveCell
...EntireRow.Insert
Range(Cells(.Row - 2, "I"), Cells(.Row - 2, "AL")).Copy _
Cells(.Row - 1, "I")
Range(Cells(.Row - 2, "B"), Cells(.Row - 2, "G")).Copy _
Cells(.Row - 1, "B")
End With
End Sub
 
T

Tom Ogilvy

Sub insertrowswithformulas()
nrows = InputBox("How many rows")
With ActiveCell
.Resize(nrows, 1).EntireRow.Insert
Range(Cells(.Row - nrows - 1, "I"), _
Cells(.Row - nrows - 1, "AL")).Copy _
Cells(.Row - nrows, "I").Resize(nrows)
Range(Cells(.Row - nrows - 1, "B"), _
Cells(.Row - nrows - 1, "G")).Copy _
Cells(.Row - nrows, "B").Resize(nrows)
End With
End Sub
 

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