ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy/Paste Revisted (https://www.excelbanter.com/excel-programming/349183-copy-paste-revisted.html)

Saxman[_5_]

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 _



All times are GMT +1. The time now is 03:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com