Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 October 4th, 2012, 09:20 PM
Authorized User
 
Join Date: Sep 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to use arrays in VBA

Hi,

I am trying to dim a constant array with values and then use it later in the VBA code.

My current code (after many iterations of trial and error) is:

Code:
Dim document_type(1 To 6) As String
document_type = Array("PRF", "SRF", "SBF", "ASF", "NPR", "ASR")
I am using Option Explicit. I am using Excel 2010. Any help is greatly appreciated!
 
Old October 7th, 2012, 01:21 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

This code looks good.

Please let us know your requirement

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old October 8th, 2012, 01:44 PM
Authorized User
 
Join Date: Sep 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The above code won't work. I've found a workaround by using:

Code:
    Dim document_type(1 To 6) As String
    document_type(1) = "PRF"
    document_type(2) = "SRF"
    document_type(3) = "SBF"
    document_type(4) = "ASF"
    document_type(5) = "NPR"
    document_type(6) = "ASR"
But there must be a way to dim the array in one statement without having to set each part individually.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrays for Controls in VBA Excel rduncan1 Excel VBA 3 October 3rd, 2010 11:10 PM
Control Arrays in VBA? Sanchin Excel VBA 3 March 24th, 2008 04:20 PM
Matrix multiplication in VBA using arrays NewVBA Excel VBA 1 June 26th, 2006 03:15 PM
Multidemmesional Arrays OR arrays gmoney060 Classic ASP Basics 3 November 1st, 2004 03:42 PM





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