ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Enter formulas in a certain number of rows, based on a cell value (https://www.excelbanter.com/excel-programming/362162-enter-formulas-certain-number-rows-based-cell-value.html)

jeffbert

Enter formulas in a certain number of rows, based on a cell value
 
I have a new item worksheet set up, for buyers to properly enter all of the
information needed to set up new sku's in our system. What I would like to
do, is have them enter the number of new items they are setting up, and then
have Excel copy all of the formulas in row 2 and paste them into the exact
number of rows equal to the number of items they are setting up.

Example:

# of sku's being set up = 15
Copy row 2 and paste it into the 15 contiguous rows from 2 thru 14

Tom Ogilvy

Enter formulas in a certain number of rows, based on a cell value
 
Sub AAA()
Dim num As Variant, rng As Range
num = InputBox("enter number of new rows")
If num = "" Then Exit Sub
If Not IsNumeric(num) Then Exit Sub
Set rng = Cells(Rows.Count, 1).End(xlUp)(2).EntireRow
Set rng = rng.Resize(num)
Rows(2).Copy rng
End Sub

--
Regards,
Tom Ogilvy

"jeffbert" wrote:

I have a new item worksheet set up, for buyers to properly enter all of the
information needed to set up new sku's in our system. What I would like to
do, is have them enter the number of new items they are setting up, and then
have Excel copy all of the formulas in row 2 and paste them into the exact
number of rows equal to the number of items they are setting up.

Example:

# of sku's being set up = 15
Copy row 2 and paste it into the 15 contiguous rows from 2 thru 14


jeffbert

Enter formulas in a certain number of rows, based on a cell va
 
Works perfectly. Once again, thanks for your help. This is the third or
fourth time that you have come through for me.


"Tom Ogilvy" wrote:

Sub AAA()
Dim num As Variant, rng As Range
num = InputBox("enter number of new rows")
If num = "" Then Exit Sub
If Not IsNumeric(num) Then Exit Sub
Set rng = Cells(Rows.Count, 1).End(xlUp)(2).EntireRow
Set rng = rng.Resize(num)
Rows(2).Copy rng
End Sub

--
Regards,
Tom Ogilvy

"jeffbert" wrote:

I have a new item worksheet set up, for buyers to properly enter all of the
information needed to set up new sku's in our system. What I would like to
do, is have them enter the number of new items they are setting up, and then
have Excel copy all of the formulas in row 2 and paste them into the exact
number of rows equal to the number of items they are setting up.

Example:

# of sku's being set up = 15
Copy row 2 and paste it into the 15 contiguous rows from 2 thru 14



All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com