View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Saxman[_5_] Saxman[_5_] is offline
external usenet poster
 
Posts: 23
Default Copy/Paste Revisted

I have finally got the following code (copy/paste from one worksheet to
another in the same workbook) to run, by including a call statement in the
main code......

Call My_Copy
--------------------------------------------
Sub My_Copy()
For i = 2 To 17
Sheets("Latest Snapshot").Range("J3:J17").Copy
Sheets("Chartdata").Cells(2, i).PasteSpecial Paste:=xlPasteValues
Application.Wait (Now + TimeValue("0:00:50"))
Next i
End Sub
-----------------------------------------------------------
However, this runs all the time and copy/pastes every 50 seconds until
condition 15 is satified. It also uses a lot of resources, thus
interfering with the running of the main code.

Could I get the above to 'turn off' until the second request and so on is
required?

I'm thinking of a the following statements:-

Select Case
For...Next
For Each Loop
Do Until LoopWhile...Wend Loop
Early Exit Loop

Or maybe resorting to the following long hand code renaming each copy/paste
as a different sub routine and call upon each one in turn? Is this
possible and how could I achieve this? Sorry to sound dumb, but I'm only
beginner!

TIA
---------------------------------------------------------------------
Option Explicit
Dim i As Integer
Sub My_Copy()
Sheets("Latest Snapshot").Select
Range("J3:J17").Select
Selection.Copy
Sheets("Chartdata").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Latest Snapshot").Select
Range("J3:J17").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Chartdata").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Latest Snapshot").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Chartdata").Select
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _