Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default simple? question about ranges


Hi,

I don`t understand why my values are transposed , hopefully someon ca
help..
I`m trying to get values into the range Arr2 based on certain criteria
Basically i guess its like

Dim Arr1 As Range
Dim Arr2() As Variant

Arr2 = Worksheets("sheet2").Range("A1:A10").Value

Set Arr1 = Worksheets("sheet1").Range("A1:J1")

For i = 1 to 10
Arr1(i,1).Value = Arr2(i,1)
next i

and it works except the values are not written into the Arr2 range but
from the first cell in Arr2 and down in the column A. I want the value
to be written from A1 to A10.
frustrate

--
hk
-----------------------------------------------------------------------
hke's Profile: http://www.excelforum.com/member.php...nfo&userid=155
View this thread: http://www.excelforum.com/showthread.php?threadid=31375

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default simple? question about ranges

if you want to put the values from arr2 into the array arr1 then

Dim Arr1 As Range
Dim Arr2() As Variant

Arr2 = Worksheets("sheet2").Range("A1:A10").Value

Set Arr1 = Worksheets("sheet1").Range("A1:J1")

For i = 1 to 10
Arr1(i,1).Value = Arr2(1,i)
next i

if to write the values form Arr2 to the range A1:A10

Set Arr1 = Worksheets("sheet1").Range("A1:J1")

Worksheets("sheet2").Range("A1:A10").Value = Application.Transpose(Arr1)


It is unclear exactly what you want to do, but perhaps the above will give
you some ideas.

--
Regards,
Tom Ogilvy




"hke" wrote in message
...

Hi,

I don`t understand why my values are transposed , hopefully someon can
help..
I`m trying to get values into the range Arr2 based on certain criteria.
Basically i guess its like

Dim Arr1 As Range
Dim Arr2() As Variant

Arr2 = Worksheets("sheet2").Range("A1:A10").Value

Set Arr1 = Worksheets("sheet1").Range("A1:J1")

For i = 1 to 10
Arr1(i,1).Value = Arr2(i,1)
next i

and it works except the values are not written into the Arr2 range but
from the first cell in Arr2 and down in the column A. I want the values
to be written from A1 to A10.
frustrated


--
hke
------------------------------------------------------------------------
hke's Profile:

http://www.excelforum.com/member.php...fo&userid=1550
View this thread: http://www.excelforum.com/showthread...hreadid=313759



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default simple? question about ranges

Tom Ogilvy wrote:
if you want to put the values from arr2 into the array arr1 then

Dim Arr1 As Range
Dim Arr2() As Variant

Arr2 = Worksheets("sheet2").Range("A1:A10").Value

Will this work in xl97? :-)


Set Arr1 = Worksheets("sheet1").Range("A1:J1")

For i = 1 to 10
Arr1(i,1).Value = Arr2(1,i)
next i

Aren't the subscripts interchanged?

if to write the values form Arr2 to the range A1:A10

Set Arr1 = Worksheets("sheet1").Range("A1:J1")

Worksheets("sheet2").Range("A1:A10").Value = Application.Transpose(Arr1)


It is unclear exactly what you want to do, but perhaps the above will give
you some ideas.


Alan Beban
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default simple? question about ranges

comments in line
"Alan Beban" wrote in message
...
Tom Ogilvy wrote:
if you want to put the values from arr2 into the array arr1 then

Dim Arr1 As Range
Dim Arr2() As Variant

Arr2 = Worksheets("sheet2").Range("A1:A10").Value

[ Arr2 = Worksheets("sheet2").Range("A1:A10").Value ] from original post
Will this work in xl97? :-)

OP's code, not mine - he maintains it is working, so it must not be xl97
(where it wouldn't work as you know).


Set Arr1 = Worksheets("sheet1").Range("A1:J1")

For i = 1 to 10
Arr1(i,1).Value = Arr2(1,i)
next i

Aren't the subscripts interchanged?

Yep, should be
Arr1(1,i).Value = Arr2(i,1)



if to write the values form Arr2 to the range A1:A10

Set Arr1 = Worksheets("sheet1").Range("A1:J1")

Worksheets("sheet2").Range("A1:A10").Value = Application.Transpose(Arr1)


It is unclear exactly what you want to do, but perhaps the above will

give
you some ideas.


Alan Beban


--
Regards,
Tom Ogilvy


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
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Named ranges interfere with simple formulas RoyWollen Excel Discussion (Misc queries) 2 September 30th 06 10:53 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
vba - need simple function to delete ranges tom g[_2_] Excel Programming 4 November 11th 04 06:58 PM
simple question, hopefully a simple answer! Matt B Excel Programming 5 January 13th 04 08:43 PM


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