Computing.Net > Forums > Office Software > VBA - Insert Row, Copy 1 Cell Down

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBA - Insert Row, Copy 1 Cell Down

Reply to Message Icon

Name: 24HG_Hoop
Date: May 18, 2008 at 12:52:57 Pacific
OS: XP Pro
CPU/Ram: 2800 / 2G
Product: clone
Comment:

Hi all,
I've got the following macro, which I use in another project, to insert N rows and copy three formulas in F9:H9. The macro I have copies down each formula into cells F10:F400, G10:G400, etc..

In a new project, I want to do a similar thing, except I only want one formula [a max()+1 formula in J2] and copy the cell contents (NOT the formula!) into the J column of my new row.

Anywho... here's the original macros. Only the last line would need changing.


Sub InsertRow()
Dim Rng, n As Long, k As Long
Application.ScreenUpdating = False
Rng = InputBox("Enter number of rows required.")
If Rng = "" Then Exit Sub
Range(ActiveCell, ActiveCell.Offset(Val(Rng) - 1, 0)).EntireRow.Insert

k = ActiveCell.Offset(-1, 0).Row
n = Cells(k, 2).End(xlToLeft).Column
Range(Cells(k, 2), Cells(k + Val(Rng), n)).FillDown

CopySideFormulaDown

End Sub


Sub CopySideFormulaDown()

Range("J2").Select.Value
Selection.AutoFill Destination:=Range("XXX"), Type:=xlFillDefault


Thx



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: May 19, 2008 at 07:27:08 Pacific
Reply:

Is there some code missing? There is no End Sub for your CopySideFormulaDown macro, so we don't if you've given us the complete macro.

In addition, what is

Range("J2").Select.Value

supposed to do? I am not familiar with the Select.Value syntax and I can't find any reference to it's use. The code gives me an Run-time error '424' Object Required when the code reaches that line.


0
Reply to Message Icon

Related Posts

See More


Batch file renaming Alt-F1 hijacked



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: VBA - Insert Row, Copy 1 Cell Down

How do I select newly inserted rows? www.computing.net/answers/office/how-do-i-select-newly-inserted-rows/9780.html

Inserting Row if variables are met www.computing.net/answers/office/inserting-row-if-variables-are-met/7814.html

Shift Excel Row Based on Cell Value www.computing.net/answers/office/shift-excel-row-based-on-cell-value/8340.html