Insert an row without using select

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I have an formated row for data, but I do not know the exact row row number
since the data amount is variable, so I make only one ready for copy and
insert after. I use the Record produced code like following:

Worksheets("printout").Rows(row + iItemStart & ":" & row + iItemStart).Select
Selection.Copy
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False

but before I can use the code, I have to make the printout sheet the
activesheet, do I have other method?

Clara
 
Worksheets("Sheet2").Range("F19:H24").Copy
Worksheets("Sheet2").Range("L206").Insert Shift:=xlDown

The two lines above will copy and insert/paste without having to have Sheet2
the active sheet. I haven't tried, but I think there's no reason you
shouldn't have code inbetween the two lines, for example to find out just
where you're going to paste the data, as long as there's no pasting or
copying or cutting in them too.
Similar code can be used to copy/insert from/to different sheets, while a
third sheet could be the active sheet all along.
 

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

Back
Top