Pasting into an active cell

B

BoRed79

I have some VBA code (see below) where I am copying a fixed selection from
one workbook (which the user has selected), into the next empty row in a
different workbook (where the macro is located).


Sheets("National").Select
Range("A6:X21").Select
Selection.Copy

Windows("Diagnostics 2010-2011.xls").Activate
Sheets("C-National").Select
Selection.paste

However, I get a run time error (438) on the paste command when I try to run
it.

Any suggestions, as I am new to VBA
 
J

Jacob Skaria

Try the below which will copy the range from the Activeworkbook Sheet
National to openworkbook Diagnostics Sheet c-national...

Sub Macro()
Dim wb As Workbook

Set wb = Workbooks("Diagnostics 2010-2011.xls")
Sheets("National").Range("A6:X21").Copy _
wb.Sheets("C-National").Range("A1")
End Sub
 
J

Jacob Skaria

To Activecell

Sub Macro()
Dim wb As Workbook

Set wb = Workbooks("Diagnostics 2010-2011.xls")
Sheets("National").Range("A6:X21").Copy _
wb.Sheets("C-National").ActiveCell
End Sub
 
M

Mike H

Hi,

Try this

Sheets("National").Range("A6:X21").Copy _
Destination:=Workbooks("Diagnostics
2010-2011.xlsx").Sheets("C-National").Range("A1")
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 

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

Top