#1   Report Post  
Posted to microsoft.public.excel.misc
Brendan Vassallo
 
Posts: n/a
Default Arrays

I am doing a mcaro where i want to take a slected range of cells and convert
it to an array so i can add it to a list box on a user form. The problem is
once I get my range of cells selected I have no idea on how to convert it to
an array and make a variable such as intAdd equal to that array so I can add
it to the list bow. Can anyone help????
--
Brendan Vassallo
  #2   Report Post  
Posted to microsoft.public.excel.misc
NAVEEN
 
Posts: n/a
Default Arrays

Hi Brendan Vassallo,

Following sample code will copy A1:A10 in Sheet1 to MyArray and also
populates to lstPopulate.

================================================== =
Private Sub cmdPopulate_Click()
Dim MyArray(11) As String
Dim Check As Boolean
Dim Counter, NumberOfItems As Integer

Counter = 1
Check = True
Do While Check = True
If Worksheets("Sheet1").Cells(Counter, 1).Value < UCase("STOP") Then
MyArray(Counter) = Worksheets("Sheet1").Cells(Counter, 1).Value
Counter = Counter + 1
Else
Check = False
End If
Loop

NumberOfItems = Counter
For Counter = 1 To NumberOfItems
lstPopulate.AddItem MyArray(Counter)
Next Counter

End Sub

================================================== =

However I have pasted below the complete code for userform for you.

================================================== =
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Populate
Caption = "Populate"
ClientHeight = 4425
ClientLeft = 45
ClientTop = 435
ClientWidth = 5040
OleObjectBlob = "Populate.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "Populate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdPopulate_Click()
Dim MyArray(11) As String
Dim Check As Boolean
Dim Counter, NumberOfItems As Integer

Counter = 1
Check = True
Do While Check = True
If Worksheets("Sheet1").Cells(Counter, 1).Value < UCase("STOP") Then
MyArray(Counter) = Worksheets("Sheet1").Cells(Counter, 1).Value
Counter = Counter + 1
Else
Check = False
End If
Loop

NumberOfItems = Counter
For Counter = 1 To NumberOfItems
lstPopulate.AddItem MyArray(Counter)
Next Counter

End Sub

Private Sub cmdQuit_Click()
End
End Sub

================================================== =

With kind regards

NAVEEN




"Brendan Vassallo" wrote:

I am doing a mcaro where i want to take a slected range of cells and convert
it to an array so i can add it to a list box on a user form. The problem is
once I get my range of cells selected I have no idea on how to convert it to
an array and make a variable such as intAdd equal to that array so I can add
it to the list bow. Can anyone help????
--
Brendan Vassallo

  #3   Report Post  
Posted to microsoft.public.excel.misc
JMB
 
Posts: n/a
Default Arrays

Actually, your range object is an array. You can access individual cells by

Selection(3,2).Value

You should be able to just drop your selection object into the listbox.

Sub test()
UserForm1.ListBox1.Clear
UserForm1.ListBox1.List = Selection.Value
UserForm1.Show
End Sub

"Brendan Vassallo" wrote:

I am doing a mcaro where i want to take a slected range of cells and convert
it to an array so i can add it to a list box on a user form. The problem is
once I get my range of cells selected I have no idea on how to convert it to
an array and make a variable such as intAdd equal to that array so I can add
it to the list bow. Can anyone help????
--
Brendan Vassallo

  #4   Report Post  
Posted to microsoft.public.excel.misc
Brendan Vassallo
 
Posts: n/a
Default Arrays

thanks guys...that worked
--
Brendan Vassallo


"Brendan Vassallo" wrote:

I am doing a mcaro where i want to take a slected range of cells and convert
it to an array so i can add it to a list box on a user form. The problem is
once I get my range of cells selected I have no idea on how to convert it to
an array and make a variable such as intAdd equal to that array so I can add
it to the list bow. Can anyone help????
--
Brendan Vassallo

  #5   Report Post  
Posted to microsoft.public.excel.misc
JMB
 
Posts: n/a
Default Arrays

you're welcome.

"Brendan Vassallo" wrote:

thanks guys...that worked
--
Brendan Vassallo


"Brendan Vassallo" wrote:

I am doing a mcaro where i want to take a slected range of cells and convert
it to an array so i can add it to a list box on a user form. The problem is
once I get my range of cells selected I have no idea on how to convert it to
an array and make a variable such as intAdd equal to that array so I can add
it to the list bow. Can anyone help????
--
Brendan Vassallo

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
vba adding arrays Jeff Excel Discussion (Misc queries) 1 November 4th 05 02:50 PM
3D Arrays DB Excel Worksheet Functions 2 October 10th 05 03:50 PM
Two arrays need highlight duplicate in one of the array Luke Excel Worksheet Functions 4 July 25th 05 08:41 PM
Confused about arrays and ranges in functions Llurker Excel Worksheet Functions 0 July 7th 05 05:44 AM
Comparing Arrays TangentMemory Excel Discussion (Misc queries) 2 May 13th 05 05:06 PM


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