![]() |
Range Offset Error
After I run it; the value are placed in a stair step down, as in th next range "F8" starts in "H8" its not right.... I would like to run this: For Each cell In MyRange2 If cell.Value 0 Then myrange.Offset(0, x) = cell.Value x = x + 1 End If Next cell down multiple rows...same for each loop... please help CODE PASTED BELOW Sub Benchmark() Dim myrange As Range Dim x As Integer Dim MyRange2 As Range Dim t As Integer x = 0 For t = 0 To 44 Set MyRange2 = Sheets("appendix").Range("p7:cq7") Set MyRange2 = MyRange2.Offset(t, 0) Set myrange = Sheets("appendix").Range("f7") Set myrange = myrange.Offset(t, 0) For Each cell In MyRange2 If cell.Value 0 Then myrange.Offset(0, x) = cell.Value x = x + 1 End If Next cell Next t Set MyRange2 = Nothing Set myrange = Nothing End Su -- NetWave12 ----------------------------------------------------------------------- NetWave128's Profile: http://www.excelforum.com/member.php...nfo&userid=229 View this thread: http://www.excelforum.com/showthread.php?threadid=27579 |
Range Offset Error
NetWave182 I think you need to change your code to: For Each cell In MyRange2 If cell.Value 0 Then x = x + 1<<<<<<< Move to here..... myrange.Offset(0, x) = cell.Value End If Next cell Charle -- Charle ----------------------------------------------------------------------- Charles's Profile: http://www.excelforum.com/member.php...nfo&userid=601 View this thread: http://www.excelforum.com/showthread.php?threadid=27579 |
Range Offset Error
Offset(RowOffset,ColumnOffset) not (Column, Row). Hard to say if you have
this backwards or not. -- George Nicholson Remove 'Junk' from return address. "NetWave128" wrote in message ... After I run it; the value are placed in a stair step down, as in the next range "F8" starts in "H8" its not right.... I would like to run this: For Each cell In MyRange2 If cell.Value 0 Then myrange.Offset(0, x) = cell.Value x = x + 1 End If Next cell down multiple rows...same for each loop... please help CODE PASTED BELOW Sub Benchmark() Dim myrange As Range Dim x As Integer Dim MyRange2 As Range Dim t As Integer x = 0 For t = 0 To 44 Set MyRange2 = Sheets("appendix").Range("p7:cq7") Set MyRange2 = MyRange2.Offset(t, 0) Set myrange = Sheets("appendix").Range("f7") Set myrange = myrange.Offset(t, 0) For Each cell In MyRange2 If cell.Value 0 Then myrange.Offset(0, x) = cell.Value x = x + 1 End If Next cell Next t Set MyRange2 = Nothing Set myrange = Nothing End Sub -- NetWave128 ------------------------------------------------------------------------ NetWave128's Profile: http://www.excelforum.com/member.php...fo&userid=2297 View this thread: http://www.excelforum.com/showthread...hreadid=275799 |
All times are GMT +1. The time now is 05:33 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com