Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 17th, 2003, 04:08 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Arrays

Please Help!

I have some data in a colum that can vary in the amount of rows. I would like to assign this data to an array. I would then like to populate some columns in my worksheet the data in the array.

Many thanks
Llewellyn Jones
 
Old July 3rd, 2003, 12:03 PM
Authorized User
 
Join Date: Jul 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

use a loop to iterate the cells, placing each cells' data into a variable of an array

Use dynamic arrays if the amount of cells can vary.

hope that helps
Tek
 
Old July 3rd, 2003, 12:07 PM
Ben Ben is offline
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why not create a named range as it will automatically vary in size.

Ben
 
Old July 8th, 2003, 05:50 AM
Authorized User
 
Join Date: Jul 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alex_read
Default

Quick sample....
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim rngUsedColACells As Range
    Dim strAryColACellVals() As String
    Dim intLoopCounter As Integer

    Set rngUsedColACells = Range("A1:A" & Worksheets(1).UsedRange.Rows.Count)
    intLoopCounter = 0

    For Each cell In rngUsedColACells
        ReDim Preserve strAryColACellVals(intLoopCounter)
        strAryColACellVals(intLoopCounter) = cell.Value

        intLoopCounter = intLoopCounter + 1
    Next cell
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help With Arrays Crippy Ruby 2 March 6th, 2013 05:59 PM
arrays ozPATT Excel VBA 2 November 4th, 2005 06:11 AM
Multidemmesional Arrays OR arrays gmoney060 Classic ASP Basics 3 November 1st, 2004 03:42 PM
Arrays tajin Excel VBA 0 June 20th, 2004 09:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.