Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Set Array equal to Range

I currently have an array of userform control values. I need to list these
controls values in a column. I currently use a For...Next Loop to list the
elements, but I would like to not use a loop. The could I have below doesn't
work, why?

Option Base 1

Sub Test()

Dim aryControls As Variant

aryControls = Array(Control1, Control2, Control3, etc.)
Sheets("Data Storage").Range(Cells(1, lngColumn), Cells(UBound(ctlArray),
lngColumn)).Value = ctlArray

End Sub
--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Set Array equal to Range

To write an array to a range the array will have to be a 2-D array and yours
is a 1-D array.
Why worry about the For Next loop? Your array is very small, so
performance-wise it won't make a difference.

RBS


"RyanH" wrote in message
...
I currently have an array of userform control values. I need to list these
controls values in a column. I currently use a For...Next Loop to list
the
elements, but I would like to not use a loop. The could I have below
doesn't
work, why?

Option Base 1

Sub Test()

Dim aryControls As Variant

aryControls = Array(Control1, Control2, Control3, etc.)
Sheets("Data Storage").Range(Cells(1, lngColumn), Cells(UBound(ctlArray),
lngColumn)).Value = ctlArray

End Sub
--
Cheers,
Ryan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Set Array equal to Range

I really would like to learn how. The Loop works great, but I am trying to
learn to work with Array a little more. Is there a way to make it a
2-dimensional Array and make this code work?
--
Cheers,
Ryan


"RB Smissaert" wrote:

To write an array to a range the array will have to be a 2-D array and yours
is a 1-D array.
Why worry about the For Next loop? Your array is very small, so
performance-wise it won't make a difference.

RBS


"RyanH" wrote in message
...
I currently have an array of userform control values. I need to list these
controls values in a column. I currently use a For...Next Loop to list
the
elements, but I would like to not use a loop. The could I have below
doesn't
work, why?

Option Base 1

Sub Test()

Dim aryControls As Variant

aryControls = Array(Control1, Control2, Control3, etc.)
Sheets("Data Storage").Range(Cells(1, lngColumn), Cells(UBound(ctlArray),
lngColumn)).Value = ctlArray

End Sub
--
Cheers,
Ryan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Set Array equal to Range

Well, you can dim a 2-D array, loop through your 1-D array and copy to the
2-D array, but you won't gain much there.

RBS


"RyanH" wrote in message
...
I really would like to learn how. The Loop works great, but I am trying to
learn to work with Array a little more. Is there a way to make it a
2-dimensional Array and make this code work?
--
Cheers,
Ryan


"RB Smissaert" wrote:

To write an array to a range the array will have to be a 2-D array and
yours
is a 1-D array.
Why worry about the For Next loop? Your array is very small, so
performance-wise it won't make a difference.

RBS


"RyanH" wrote in message
...
I currently have an array of userform control values. I need to list
these
controls values in a column. I currently use a For...Next Loop to list
the
elements, but I would like to not use a loop. The could I have below
doesn't
work, why?

Option Base 1

Sub Test()

Dim aryControls As Variant

aryControls = Array(Control1, Control2, Control3, etc.)
Sheets("Data Storage").Range(Cells(1, lngColumn),
Cells(UBound(ctlArray),
lngColumn)).Value = ctlArray

End Sub
--
Cheers,
Ryan




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Set Array equal to Range

So there is no way to set a Variant Variable to a 2D Array? For example,

ctrlArray = Array(Array(Control1, Control2, etc.),Array(""))
--
Cheers,
Ryan


"RB Smissaert" wrote:

Well, you can dim a 2-D array, loop through your 1-D array and copy to the
2-D array, but you won't gain much there.

RBS


"RyanH" wrote in message
...
I really would like to learn how. The Loop works great, but I am trying to
learn to work with Array a little more. Is there a way to make it a
2-dimensional Array and make this code work?
--
Cheers,
Ryan


"RB Smissaert" wrote:

To write an array to a range the array will have to be a 2-D array and
yours
is a 1-D array.
Why worry about the For Next loop? Your array is very small, so
performance-wise it won't make a difference.

RBS


"RyanH" wrote in message
...
I currently have an array of userform control values. I need to list
these
controls values in a column. I currently use a For...Next Loop to list
the
elements, but I would like to not use a loop. The could I have below
doesn't
work, why?

Option Base 1

Sub Test()

Dim aryControls As Variant

aryControls = Array(Control1, Control2, Control3, etc.)
Sheets("Data Storage").Range(Cells(1, lngColumn),
Cells(UBound(ctlArray),
lngColumn)).Value = ctlArray

End Sub
--
Cheers,
Ryan






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Set Array equal to Range

Don't think so.

RBS


"RyanH" wrote in message
...
So there is no way to set a Variant Variable to a 2D Array? For example,

ctrlArray = Array(Array(Control1, Control2, etc.),Array(""))
--
Cheers,
Ryan


"RB Smissaert" wrote:

Well, you can dim a 2-D array, loop through your 1-D array and copy to
the
2-D array, but you won't gain much there.

RBS


"RyanH" wrote in message
...
I really would like to learn how. The Loop works great, but I am trying
to
learn to work with Array a little more. Is there a way to make it a
2-dimensional Array and make this code work?
--
Cheers,
Ryan


"RB Smissaert" wrote:

To write an array to a range the array will have to be a 2-D array and
yours
is a 1-D array.
Why worry about the For Next loop? Your array is very small, so
performance-wise it won't make a difference.

RBS


"RyanH" wrote in message
...
I currently have an array of userform control values. I need to list
these
controls values in a column. I currently use a For...Next Loop to
list
the
elements, but I would like to not use a loop. The could I have
below
doesn't
work, why?

Option Base 1

Sub Test()

Dim aryControls As Variant

aryControls = Array(Control1, Control2, Control3, etc.)
Sheets("Data Storage").Range(Cells(1, lngColumn),
Cells(UBound(ctlArray),
lngColumn)).Value = ctlArray

End Sub
--
Cheers,
Ryan





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Set Array equal to Range

but I would like to not use a loop.

Hi. These are not controls, but does this idea help?

Sub Demo()
Dim v
v = Array(11, 12, 13)

Range("B1").Resize(3) = WorksheetFunction.Transpose(v)
End Sub

- - -
HTH
Dana DeLouis



RyanH wrote:
I currently have an array of userform control values. I need to list these
controls values in a column. I currently use a For...Next Loop to list the
elements, but I would like to not use a loop. The could I have below doesn't
work, why?

Option Base 1

Sub Test()

Dim aryControls As Variant

aryControls = Array(Control1, Control2, Control3, etc.)
Sheets("Data Storage").Range(Cells(1, lngColumn), Cells(UBound(ctlArray),
lngColumn)).Value = ctlArray

End Sub

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
Can you make Range Equal All Values in an Array? RyanH Excel Programming 9 November 14th 08 08:47 PM
Setting a range.value equal to /part/ of a (3D) variant array? ker_01 Excel Programming 3 July 21st 08 07:23 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R[_2_] Excel Programming 3 November 13th 07 04:08 PM
SUMPRODUCT - How can I use does not equal in an array? DG Excel Worksheet Functions 3 December 30th 05 06:53 PM
What cells in a array equal my value? Stephen Excel Worksheet Functions 10 July 20th 05 08:59 PM


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