Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Difficulty with copy and paste

Once again, I am trying to do something simple. I can get it to work with
macros, but when I modify the code, it doesn't seem to want to work anymore.
I am trying to copy a given range (A4:H4) and paste it to a cell that can
change.

Here is the code I am using:

Dim copy_range As Range
Call cell_setup 'this is where cell_range is properly defined (it works in
the later code fine)

' create new row
Set copy_range = Worksheets("Purchase
Requisition").Range(cell_range.Offset(cell_count, 7))
Range("A4:H4").Select
Application.CutCopyMode = False 'something the macro made
Selection.Copy
copy_range.Paste



I would think this would work:

' create new row
Set copy_range = Worksheets("Purchase
Requisition").Range(cell_range.Offset(cell_count, 7))
Range("A4:H4").Copy
copy_range.Paste

but... it doesn't seem to want to

I get a "Run-time error '1004':Application-defined or object-defined error"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Difficulty with copy and paste

It looks like this:
Set copy_range = Worksheets("Purchase Requisition") _
..Range(cell_range.Offset(cell_count, 7))

Needs to be changed to:

Set copy_range = Worksheets("Purchase Requisition") _
..Cells(cell_range.Offset(cell_count, 7))




"baconcow" wrote:

Once again, I am trying to do something simple. I can get it to work with
macros, but when I modify the code, it doesn't seem to want to work anymore.
I am trying to copy a given range (A4:H4) and paste it to a cell that can
change.

Here is the code I am using:

Dim copy_range As Range
Call cell_setup 'this is where cell_range is properly defined (it works in
the later code fine)

' create new row
Set copy_range = Worksheets("Purchase
Requisition").Range(cell_range.Offset(cell_count, 7))
Range("A4:H4").Select
Application.CutCopyMode = False 'something the macro made
Selection.Copy
copy_range.Paste



I would think this would work:

' create new row
Set copy_range = Worksheets("Purchase
Requisition").Range(cell_range.Offset(cell_count, 7))
Range("A4:H4").Copy
copy_range.Paste

but... it doesn't seem to want to

I get a "Run-time error '1004':Application-defined or object-defined error"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Difficulty with copy and paste

I don't know, after looking closer, I think you also have Parentheses in the
wrong place. Maybe

Set copy_range = Worksheets("Purchase Requisition") _
..Range(cell_range).Offset(cell_count, 7)


"baconcow" wrote:

Once again, I am trying to do something simple. I can get it to work with
macros, but when I modify the code, it doesn't seem to want to work anymore.
I am trying to copy a given range (A4:H4) and paste it to a cell that can
change.

Here is the code I am using:

Dim copy_range As Range
Call cell_setup 'this is where cell_range is properly defined (it works in
the later code fine)

' create new row
Set copy_range = Worksheets("Purchase
Requisition").Range(cell_range.Offset(cell_count, 7))
Range("A4:H4").Select
Application.CutCopyMode = False 'something the macro made
Selection.Copy
copy_range.Paste



I would think this would work:

' create new row
Set copy_range = Worksheets("Purchase
Requisition").Range(cell_range.Offset(cell_count, 7))
Range("A4:H4").Copy
copy_range.Paste

but... it doesn't seem to want to

I get a "Run-time error '1004':Application-defined or object-defined error"

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Difficulty with copy and paste

In the end, I could only get it to work with this code:

Set copy_range = Worksheets("Purchase Requisition") _
..Range(cell_range.Offset(cell_count, 0), cell_range.Offset(cell_count, 7))
Range("A4:H4").Copy
copy_range.Select
ActiveSheet.Paste

It seemed to want the entire range, from one end to the other, as opposed to
just the first cell I wanted to paste it to, like the Macro had.
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
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Automating copy/paste/paste special when row references change Carl LaFong Excel Programming 4 October 8th 07 06:10 AM
help w/ generic copy & paste/paste special routine DavidH[_2_] Excel Programming 5 January 23rd 06 03:58 AM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM


All times are GMT +1. The time now is 01:44 PM.

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"