Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Pasting into an active cell

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Pasting into an active cell

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



--
Jacob


"BoRed79" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Pasting into an active cell

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


--
Jacob


"BoRed79" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Pasting into an active cell

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.


"BoRed79" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pasting active links in excel Horse Excel Discussion (Misc queries) 0 March 5th 10 11:43 PM
Macro for pasting on active column igorin Excel Programming 2 March 6th 09 10:01 PM
Deselecting active cells after pasting Dazza Excel Programming 2 October 16th 06 10:47 AM
pasting textbox value to active cell ASU Excel Discussion (Misc queries) 2 June 23rd 06 03:58 PM
Opening and pasting in active workbook TR[_2_] Excel Programming 3 July 29th 04 02:16 PM


All times are GMT +1. The time now is 05:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"