Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Ranges and Arrays - Passing values

Hi,

I can populate an array from a range quite easily, e.g.

Dim TestArray as Variant
TestArray = Range("C5").CurrentRegion.Value

Is there a way to pass values back to the range in a similar fashion ?
That is, without referring to the individual Array and Cell co-ordinates.

regards,
Don


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Ranges and Arrays - Passing values

Hi again,

Sorry to have bothered you but Problem solved. e.g.

Range("C5:F13").Value = TestArray

Thanks and regards,
Don

"Don Lloyd" wrote in message
...
Hi,

I can populate an array from a range quite easily, e.g.

Dim TestArray as Variant
TestArray = Range("C5").CurrentRegion.Value

Is there a way to pass values back to the range in a similar fashion ?
That is, without referring to the individual Array and Cell co-ordinates.

regards,
Don



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Ranges and Arrays - Passing values

Just to mention an idea. With the use of "CurrentRegion," your array size
is unknown. However, the output range (C5:F13) is "hard coded." See if
you could use this general idea.

Sub Demo()
Dim TestArray
TestArray = Range("C5").CurrentRegion.Value
'// Your code here...then

Range("C5").Resize _
(UBound(TestArray, 1), UBound(TestArray, 2)) = TestArray
End Sub

HTH
--
Dana DeLouis
Win XP & Office 2003


"Don Lloyd" wrote in message
...
Hi again,

Sorry to have bothered you but Problem solved. e.g.

Range("C5:F13").Value = TestArray

Thanks and regards,
Don

"Don Lloyd" wrote in message
...
Hi,

I can populate an array from a range quite easily, e.g.

Dim TestArray as Variant
TestArray = Range("C5").CurrentRegion.Value

Is there a way to pass values back to the range in a similar fashion ?
That is, without referring to the individual Array and Cell co-ordinates.

regards,
Don





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Ranges and Arrays - Passing values

Dana DeLouis wrote:

Just to mention an idea. With the use of "CurrentRegion," your array size
is unknown. However, the output range (C5:F13) is "hard coded." See if
you could use this general idea.

Sub Demo()
Dim TestArray
TestArray = Range("C5").CurrentRegion.Value
'// Your code here...then

Range("C5").Resize _
(UBound(TestArray, 1), UBound(TestArray, 2)) = TestArray
End Sub

HTH

Or if TestArray might be (or have been changed by your code to) a
0-based array, substitute

Range("C5").Resize(UBound(TestArray,1)-LBound(TestArray,1)+1, _
UBound(TestArray,2)-LBound(TestArray,2)+1) = TestArray

Alan Beban
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Ranges and Arrays - Passing values

Thank you Dana and Alan for your useful and informative notes.

regards
Don

"Don Lloyd" wrote in message
...
Hi,

I can populate an array from a range quite easily, e.g.

Dim TestArray as Variant
TestArray = Range("C5").CurrentRegion.Value

Is there a way to pass values back to the range in a similar fashion ?
That is, without referring to the individual Array and Cell co-ordinates.

regards,
Don



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
General Question regarding passing cells, ranges, cell values through subs & functions [email protected] Excel Programming 0 September 5th 04 06:56 PM
General Question regarding passing cells, ranges, cell values through subs & functions [email protected] Excel Programming 1 September 5th 04 06:46 PM
General Question regarding passing cells, ranges, cell values through subs & functions [email protected] Excel Programming 2 September 5th 04 06:03 AM
General Question regarding passing cells, ranges, cell values through subs & functions [email protected] Excel Programming 1 September 4th 04 10:40 PM
General Question regarding passing cells, ranges, cell values through subs & functions [email protected] Excel Programming 1 September 4th 04 09:09 PM


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