Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Copying and Pasting in a Loop

Janos,

Try:

Sub TEST()

Const limitDOWN As Date = #1/1/2007#
Const limitUP As Date = #2/2/2007#
Const isDOMESTIC As String = "Y"
Dim c As Range
Dim d As Range

For Each c In Worksheets("Instructions").Range("E7:E200").Cells
If c.Value limitDOWN And c.Value < limitUP And _
c.Offset(0, -3).Value = isDOMESTIC Then
c.Resize(1, 7).Copy
Worksheets("Janos").Range("A65536").End(xlUp)(2).P asteSpecial
Paste:=xlValues
End If
Next c

MsgBox "All done!"

End Sub

HTH,
Bernie
MS Excel MVP


"Janos" wrote in message
...
Hello, once again I implore the help of the Excel gods oin the ether!
I'm so sorry to ask another silly question, but how do I copy and then
paste
ranges in a loop. The idea is that once i check for two conditions to be
true, i need to copy that range and paste it into another (existing)
worksheet. I tried to do it with a nested loop, but it's not working. See
beklow for code.

Any ideas?

Thank you very much!

Sub TEST()

Const limitDOWN As Date = #1/1/2007#
Const limitUP As Date = #2/2/2007#
Const isDOMESTIC As String = "Y"
Dim c As Range
Dim d As Range

For Each c In Worksheets("Instructions").Range("E7:E200").Cells
If c.Value limitDOWN And c.Value < limitUP And _
c.Offset(0, -3).Value = isDOMESTIC Then
With c.Range(Cells(1, 1), Cells(1, 7)).Copy
For Each d In Worksheets("Janos").Range("A5").Cells
d.Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Next d
End With
End If
Next c

MsgBox "All done!"

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
Copying & Pasting sjmonroe Excel Discussion (Misc queries) 5 November 20th 09 09:32 PM
Loop vertically, copying and pasting inputs for each cell in Col A Jef Gorbach Excel Programming 0 December 16th 06 06:39 AM
Loop for copying data, then pasting in a continuous row Bhupinder Rayat Excel Programming 5 July 7th 06 04:31 PM
Setting up some sort of cutting and pasting loop Trickster Excel Worksheet Functions 4 July 20th 05 07:13 AM
copying and pasting loop Kenneth Smith Excel Programming 1 November 6th 03 03:51 PM


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