Visual Basic for Applications (VBA) is a programming language used in login scripts. Administrators use VBA to program settings for users when they log in to the network. An array is a variable that lets you contain several values in one variable. It is beneficial if you have a long list of values you want to use in your code. You can edit a VBA file using a simple text editor such as Notepad.
Right-click the VBS file on the computer and select "Edit." The VBS file code opens. Scroll down the file to the location where you want to add the array.
Type the following code to create an array variable:
Dim myarray(1 To 10) As String
This array variable is named "myarray." It can contain up to ten string values.
Assign values to the array. In this example, the first two indexes in the array are assigned colors. The following code is how you assign values to your array:
myarray(0) = "orange"
myarray(1) = "blue"
Notice that the first value in an array is "0." The "0th" index is always the first value in an array.
Click the "File" menu item and select "Save." The changes to the VBA file are saved to the code.
How to Write Visual Basic Array Data to a Text File in Excel
Microsoft Visual Basic for Applications (VBA) was developed by Microsoft and it's commonly used to automate routine tasks within Microsoft Office applications....
How to Duplicate Data & Sort a VBA Multidimensional Array in Excel
Visual Basic Application (VBA) is the programming language that Excel incorporates into its Macro editor. The VBE (Visual Basic Editor) Macro editor...
How to Clean a String in VBA
As a Visual Basic for Applications programmer, you should be able to remove numbers or characters in strings to display correct information...
VBA: How to Determine an Array Size
Using arrays in Visual Basic for Applications, or VBA, procedures efficiently manages large amounts of data, and saves memory and execution time....
How to Remove Duplicate Array Rows in Excel VBA
Removing duplicate data from an array using Visual Basic for Applications (VBA) in Excel can be confusing if you're not an experienced...
How to Sort a String Array in VBA
Sorting a string array in Visual Basic for Applications (VBA) is not as simple as in other, more recent programming languages. In...