ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy cell contents using Input Box (https://www.excelbanter.com/excel-programming/340477-copy-cell-contents-using-input-box.html)

cottage6

Copy cell contents using Input Box
 
I need to copy down the contents of a cell the number of cells specified in
an Input Box. I first need to find the last used cell in the column as the
data will keep apending each month. LastRow equals the number in the Input
Box and I can combine that with the Column letter, but I'm having a problem
getting the last used cell address. So if the last cell in the column is M79,
I want to copy the contents down the number of cells in the Input Box. I
hope I've explained this well enough; don't laugh too hard, I'm not very good
at this. Any help would be greatly appreciated as always.

Dim LastRow As Long
Dim FirstRow As Range
Range("M65536").End(xlUp)(1).Select
LastRow = Application.InputBox("How many categories?")
FirstRow = ActiveCell

With Worksheets("Margin %")
.Range("FirstRow:M" & LastRow).FillDown
End With

Bob Phillips[_6_]

Copy cell contents using Input Box
 
Dim LastRow As Long
Dim FirstRow As Range

LastRow = Application.InputBox("How many categories?")
Set FirstRow = Range("M65536").End(xlUp)

With Worksheets("Margin %")
FirstRow.Resize(LastRow).FillDown
End With


--
HTH

Bob Phillips

"cottage6" wrote in message
...
I need to copy down the contents of a cell the number of cells specified

in
an Input Box. I first need to find the last used cell in the column as

the
data will keep apending each month. LastRow equals the number in the

Input
Box and I can combine that with the Column letter, but I'm having a

problem
getting the last used cell address. So if the last cell in the column is

M79,
I want to copy the contents down the number of cells in the Input Box. I
hope I've explained this well enough; don't laugh too hard, I'm not very

good
at this. Any help would be greatly appreciated as always.

Dim LastRow As Long
Dim FirstRow As Range
Range("M65536").End(xlUp)(1).Select
LastRow = Application.InputBox("How many categories?")
FirstRow = ActiveCell

With Worksheets("Margin %")
.Range("FirstRow:M" & LastRow).FillDown
End With




Vacation's Over

Copy cell contents using Input Box
 
Try

Dim LastRow As Long
Dim AddRows As variant

With Worksheets("Margin %")
LastRow = .Range("M65536").End(xlUp).Row
AddRows = Application.InputBox("How many categories?")
if Isnumeric(addrows) then
.Range(Cells( LastRow, 13), Cells ( LastRow + AddRows, 13)).FillDown
else
msgbox "Please input a number!"
end if
End With

"cottage6" wrote:

I need to copy down the contents of a cell the number of cells specified in
an Input Box. I first need to find the last used cell in the column as the
data will keep apending each month. LastRow equals the number in the Input
Box and I can combine that with the Column letter, but I'm having a problem
getting the last used cell address. So if the last cell in the column is M79,
I want to copy the contents down the number of cells in the Input Box. I
hope I've explained this well enough; don't laugh too hard, I'm not very good
at this. Any help would be greatly appreciated as always.

Dim LastRow As Long
Dim FirstRow As Range
Range("M65536").End(xlUp)(1).Select
LastRow = Application.InputBox("How many categories?")
FirstRow = ActiveCell

With Worksheets("Margin %")
.Range("FirstRow:M" & LastRow).FillDown
End With


cottage6

Copy cell contents using Input Box
 
Bob, thanks for the solution to my problem. I appreciate it very much. I
didn't try Vacation's Over's solution because yours worked and I didn't need
to, but thanks for that response as well!

"Bob Phillips" wrote:

Dim LastRow As Long
Dim FirstRow As Range

LastRow = Application.InputBox("How many categories?")
Set FirstRow = Range("M65536").End(xlUp)

With Worksheets("Margin %")
FirstRow.Resize(LastRow).FillDown
End With


--
HTH

Bob Phillips

"cottage6" wrote in message
...
I need to copy down the contents of a cell the number of cells specified

in
an Input Box. I first need to find the last used cell in the column as

the
data will keep apending each month. LastRow equals the number in the

Input
Box and I can combine that with the Column letter, but I'm having a

problem
getting the last used cell address. So if the last cell in the column is

M79,
I want to copy the contents down the number of cells in the Input Box. I
hope I've explained this well enough; don't laugh too hard, I'm not very

good
at this. Any help would be greatly appreciated as always.

Dim LastRow As Long
Dim FirstRow As Range
Range("M65536").End(xlUp)(1).Select
LastRow = Application.InputBox("How many categories?")
FirstRow = ActiveCell

With Worksheets("Margin %")
.Range("FirstRow:M" & LastRow).FillDown
End With





Vacation's Over

Copy cell contents using Input Box
 
Add my isnumeric line to Bob's code and you are all set

"cottage6" wrote:

Bob, thanks for the solution to my problem. I appreciate it very much. I
didn't try Vacation's Over's solution because yours worked and I didn't need
to, but thanks for that response as well!

"Bob Phillips" wrote:

Dim LastRow As Long
Dim FirstRow As Range

LastRow = Application.InputBox("How many categories?")
Set FirstRow = Range("M65536").End(xlUp)

With Worksheets("Margin %")
FirstRow.Resize(LastRow).FillDown
End With


--
HTH

Bob Phillips

"cottage6" wrote in message
...
I need to copy down the contents of a cell the number of cells specified

in
an Input Box. I first need to find the last used cell in the column as

the
data will keep apending each month. LastRow equals the number in the

Input
Box and I can combine that with the Column letter, but I'm having a

problem
getting the last used cell address. So if the last cell in the column is

M79,
I want to copy the contents down the number of cells in the Input Box. I
hope I've explained this well enough; don't laugh too hard, I'm not very

good
at this. Any help would be greatly appreciated as always.

Dim LastRow As Long
Dim FirstRow As Range
Range("M65536").End(xlUp)(1).Select
LastRow = Application.InputBox("How many categories?")
FirstRow = ActiveCell

With Worksheets("Margin %")
.Range("FirstRow:M" & LastRow).FillDown
End With






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

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