Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Problem with Loop

I have the following code so far:
row1 = 2

Do Until Sheets("OLE1").Range("L" & row1).Value = Empty
If Trim(Sheets("OLE1").Range("M" & row1).Value) < "" Then

Sheets("OLE1").Range("K" & row1).Copy
Sheets("OLE1").Range("K" & row1 + 1).PasteSpecial Paste:=xlPasteValues
'' Sheets("OLE1").Range("K" & row1 + 1).Select

End If
row1 = row1 + 1
Sheets("OLE1").Range("K" & row1 + 1).Select
Loop
End Sub


Example of my data:

K L M
1 1280.98 SB014
2 20522.19 SB014
3 11401.21 SB014
4 12365.00 SB014 1.10000
5 1594.00 SB014 1.10000
6 665.00 SB014 7.75375
7 154.00 SB014 7.75375

Is it possible to copy K4 to K5 and then the code move to K6 and copy K6 to
K7?

Cheers!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Problem with Loop

It appears to me that the DO statement checks the cell you just copied into.
Are you seeing the value in K2 copied into K3, K4, ... and a LONG way down?

If you are trying to copy even numbered rows (2, 4, 6) to the odd numbered
row below them (3, 5, 7 respectively), you probably want to increment your
row1 index by 2 instead of 1 (row1 = row1 + 2).
Jerry K

"Rachel" wrote in message
...
I have the following code so far:
row1 = 2

Do Until Sheets("OLE1").Range("L" & row1).Value = Empty
If Trim(Sheets("OLE1").Range("M" & row1).Value) < "" Then

Sheets("OLE1").Range("K" & row1).Copy
Sheets("OLE1").Range("K" & row1 + 1).PasteSpecial Paste:=xlPasteValues
'' Sheets("OLE1").Range("K" & row1 + 1).Select

End If
row1 = row1 + 1
Sheets("OLE1").Range("K" & row1 + 1).Select
Loop
End Sub


Example of my data:

K L M
1 1280.98 SB014
2 20522.19 SB014
3 11401.21 SB014
4 12365.00 SB014 1.10000
5 1594.00 SB014 1.10000
6 665.00 SB014 7.75375
7 154.00 SB014 7.75375

Is it possible to copy K4 to K5 and then the code move to K6 and copy K6
to
K7?

Cheers!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Problem with Loop

It will not always be the case that I will be copying even to odd.
As soon as data is found in column M 'then' I want copy to the cell below
(due it being a pair - same exchange rate) and only when it has carried out
this action, I would then like it to move down two rows.
So as long as there is nothing in column M I just need it to move down one
row.
In the example below nothing needs to happen in rows 1,2,3
K4 would then be copied to K5 and K6 copied to K7


"Jerry K" wrote:

It appears to me that the DO statement checks the cell you just copied into.
Are you seeing the value in K2 copied into K3, K4, ... and a LONG way down?

If you are trying to copy even numbered rows (2, 4, 6) to the odd numbered
row below them (3, 5, 7 respectively), you probably want to increment your
row1 index by 2 instead of 1 (row1 = row1 + 2).
Jerry K

"Rachel" wrote in message
...
I have the following code so far:
row1 = 2

Do Until Sheets("OLE1").Range("L" & row1).Value = Empty
If Trim(Sheets("OLE1").Range("M" & row1).Value) < "" Then

Sheets("OLE1").Range("K" & row1).Copy
Sheets("OLE1").Range("K" & row1 + 1).PasteSpecial Paste:=xlPasteValues
'' Sheets("OLE1").Range("K" & row1 + 1).Select

End If
row1 = row1 + 1
Sheets("OLE1").Range("K" & row1 + 1).Select
Loop
End Sub


Example of my data:

K L M
1 1280.98 SB014
2 20522.19 SB014
3 11401.21 SB014
4 12365.00 SB014 1.10000
5 1594.00 SB014 1.10000
6 665.00 SB014 7.75375
7 154.00 SB014 7.75375

Is it possible to copy K4 to K5 and then the code move to K6 and copy K6
to
K7?

Cheers!




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
Loop Problem Patrick Bateman Excel Programming 1 August 30th 07 04:29 PM
Loop Problem Dave Birley Excel Programming 2 May 10th 07 07:17 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
For...Each Loop Problem SuperJas Excel Programming 4 April 2nd 04 05:01 AM
For..Next loop problem Dwaine Horton Excel Programming 1 February 18th 04 12:12 AM


All times are GMT +1. The time now is 12:35 AM.

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"