Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Copy from one worksheet to another

I have the following macro. I desire that it copy from "Orders" to
"Pofit_Loss_Statement" the value in "ID" (a drop-down list) and paste it into
the first blank line in the Profit_Loss_Statement.

The code works fine as long as I stay on the Orders worksheet. Once I
inserted the code to switch to the Profit_Loss_Statement, I started getting
Runtime Error 1004. What am I doing wrong?

Sub SelectItem()
'
' SelectItem Macro
' Macro recorded 05/20/2007 by EuGene C. White, CNA
'
Worksheets("Orders").Activate ' extra code
Range("ID").Select
Selection.Copy
Worksheets("Profit_Loss_Statement").Activate
Range("A3").Select
Do Until Cells(ActiveCell.Row + 1, 1) = ""

If ActiveCell = "" Then
Cells(ActiveCell.Row + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Else
Cells(ActiveCell.Row + 1, 1).Select
End If
Loop
Cells(ActiveCell.Row + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy from one worksheet to another

Hi Gene

See this page for a example without selecting and looping
http://www.rondebruin.nl/copy1.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Gene" wrote in message ...
I have the following macro. I desire that it copy from "Orders" to
"Pofit_Loss_Statement" the value in "ID" (a drop-down list) and paste it into
the first blank line in the Profit_Loss_Statement.

The code works fine as long as I stay on the Orders worksheet. Once I
inserted the code to switch to the Profit_Loss_Statement, I started getting
Runtime Error 1004. What am I doing wrong?

Sub SelectItem()
'
' SelectItem Macro
' Macro recorded 05/20/2007 by EuGene C. White, CNA
'
Worksheets("Orders").Activate ' extra code
Range("ID").Select
Selection.Copy
Worksheets("Profit_Loss_Statement").Activate
Range("A3").Select
Do Until Cells(ActiveCell.Row + 1, 1) = ""

If ActiveCell = "" Then
Cells(ActiveCell.Row + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Else
Cells(ActiveCell.Row + 1, 1).Select
End If
Loop
Cells(ActiveCell.Row + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Copy from one worksheet to another

This would be my approach:
Sub SelectItem()
Worksheets("Orders").Activate ' extra code
Range("ID").Copy
Worksheets("Profit_Loss_Statement").Activate
Range("A3").Activate
If ActiveCell = "" Then
ActiveCell.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Else
Do Until ActiveCell = ""
ActiveCell.Offset(1, 0).Activate
Loop
ActiveCell.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End If
End Sub

"Ron de Bruin" wrote:

Hi Gene

See this page for a example without selecting and looping
http://www.rondebruin.nl/copy1.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Gene" wrote in message ...
I have the following macro. I desire that it copy from "Orders" to
"Pofit_Loss_Statement" the value in "ID" (a drop-down list) and paste it into
the first blank line in the Profit_Loss_Statement.

The code works fine as long as I stay on the Orders worksheet. Once I
inserted the code to switch to the Profit_Loss_Statement, I started getting
Runtime Error 1004. What am I doing wrong?

Sub SelectItem()
'
' SelectItem Macro
' Macro recorded 05/20/2007 by EuGene C. White, CNA
'
Worksheets("Orders").Activate ' extra code
Range("ID").Select
Selection.Copy
Worksheets("Profit_Loss_Statement").Activate
Range("A3").Select
Do Until Cells(ActiveCell.Row + 1, 1) = ""

If ActiveCell = "" Then
Cells(ActiveCell.Row + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Else
Cells(ActiveCell.Row + 1, 1).Select
End If
Loop
Cells(ActiveCell.Row + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub


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
Copy & paste cells fr open worksheet then close the worksheet Sin Excel Programming 1 October 2nd 06 02:20 PM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie[_2_] Excel Programming 2 September 22nd 04 03:30 PM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie[_3_] Excel Programming 0 September 22nd 04 03:26 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM


All times are GMT +1. The time now is 08:38 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"