Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Stepping through a column using FOR/NEXT

Hello

I need to step through each cell of a particular column, check the contents to the previous cell, and then preform an action based on the outcome. Below is my code. Please help if you can

Thanks, Jo

With Worksheets("Source Data"
For i = 2 To .Range("e").Rows.Coun

If .Range("E" + i) < .Range("E" + (i - 1)) The

Range("e" + i).Selec
Selection.Cop
Worksheets("Gap").Range("b11").End(xlDown).Offset( 1, 0).Selec
Selection.PasteSpecial Paste:=xlPasteValue

.....etc

End I
Next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Stepping through a column using FOR/NEXT

Hi Joe, :)

here is a sample code for you.
You can specify a range like this. And don't need SELECT a cell for copy and
paste, just use Value property.
Hope it works as intended.

With Worksheets("Source Data")
For i = 2 To .Columns("E").Rows.Count
If .Range("E" & i).Value < .Range("E" & (i - 1)).Value Then
Worksheets("Gap").Range("b11").End(xlDown).Offset( 1,
0).Value = _
Range("E" & i).Value
' .....etc.
End If
Next i
End With


--
Kind Regards
Colo
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo of 'The Road of The Cell Masters' :)

URL:http://www.interq.or.jp/sun/puremis/...astersLink.htm


/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


"Joe Mathis" wrote in message
...
Hello,

I need to step through each cell of a particular column, check the

contents to the previous cell, and then preform an action based on the
outcome. Below is my code. Please help if you can.

Thanks, Joe

With Worksheets("Source Data")
For i = 2 To .Range("e").Rows.Count

If .Range("E" + i) < .Range("E" + (i - 1)) Then

Range("e" + i).Select
Selection.Copy
Worksheets("Gap").Range("b11").End(xlDown).Offset( 1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues

.....etc.

End If
Next i


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
Stepping in to a cell Max Excel Discussion (Misc queries) 3 April 27th 10 02:44 AM
Stepping through Code Jim May Excel Discussion (Misc queries) 9 October 25th 07 01:40 PM
stepping chart Petje Charts and Charting in Excel 2 July 7th 06 10:22 PM
Stepping Through vs. Play CWillis Excel Discussion (Misc queries) 1 June 15th 06 05:34 PM
Stepping thru Cell References Ralph[_4_] Excel Programming 1 September 10th 03 09:39 PM


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