Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default 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



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
OFFSET and LOOKUP Error Jim Excel Worksheet Functions 2 March 15th 10 08:42 PM
Error in Function OFFSET Daniel Utsch[_2_] Excel Worksheet Functions 5 January 29th 09 04:50 PM
#REF Error in Named Range with INDIRECT, SUMPRODUCT, and OFFSET Greg in CO[_2_] Excel Worksheet Functions 6 October 13th 08 06:45 PM
Offset/match returns #value error Geoff Excel Worksheet Functions 8 May 7th 08 03:56 AM
Offset delivers value error with Named range [email protected] Excel Worksheet Functions 4 November 29th 05 12:49 PM


All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"