?
Solved

How to write a VB script in Excel to copy from a cell range and paste to another while inserting a new row?

Posted on 2006-07-06
3
Medium Priority
?
3,026 Views
Last Modified: 2007-12-19
I am trying to write a VB script that I can assign to a button on a Excel workbook. What I need the script to do is copy a cell range (i.e., a10:l10) and paste it to another area in the same spreadsheet. I also need to clear the copied cells and cause the spreadsheet where I paste the data to automatically insert a new row.  This is for an Excel spreadsheet using Microsoft VB.
0
Comment
Question by:rcjax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
jsemenak earned 1500 total points
ID: 17050042
Hi,

Sub Macro1()
    Range("A10:I10").Select
    Selection.Copy
    Range("A16").Select
    ActiveSheet.Paste
    Range("A10:I10").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Rows("16:16").Select
    Selection.Insert Shift:=xlDown
End Sub

This macro copy A10:I10 to A16 :I16 u can modify target.
0
 
LVL 1

Expert Comment

by:dapcom
ID: 17050048
Try this: (done with the macro recorder)

    Range("A1:C1").Select
    Selection.Copy
    Range("A5").Select
    Selection.Insert Shift:=xlDown
    Range("A1:C1").Delete

This actually does not insert a whole row but move the cells down for the range with only.
It should more or less do what you seek?
0
 
LVL 1

Expert Comment

by:dapcom
ID: 17050055
lol, 1 min too late :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Simple Linear Regression
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question