Step 8: We will get the message box with all the employee names in the sequence we put it. Step 7: Run this code by hitting the F5 or Run button which is placed on the topmost ribbon of VBE.
MsgBox EmployeeData(0) & ', ' & EmployeeData(1) & ', ' & EmployeeData(3) & ', ' & EmployeeData(4) And array will be in the sequence of numbers at which we have defined. Step 6: And to print the values stored in the Employee Data array we will use MsgBox. And it should be in the way as we do concatenation.ĮmployeeData = Array('Anand', 'Shraddha', 'Aniket', 'Ashwani', 'Deepinder') We have Anand, Shraddha, Aniket, Ashwani, and Deepinder as Employee names. Step 5: Now consider the names of employees which we will be using here. The reason for seeing the Variant data type is because we can store any type of value in it. Step 4: Now use the same variable which we declared above and use Array function.Īs we can see, as per the syntax of Array, it only allows Variant data type and Argument List (). But as the data may vary so using Variant will be good. We can choose String or Integer or Variant. For this declare a variable in a similar name and put brackets “( )” after that. Step 3: Now we will be using Employee names for creating the array.
Step 2: Define the subprocedure preferably in the name of VBA String Array or we can choose any name as per our choice.