Here is what I have done so far.
Sub MP_division()
Worksheets(3).Activate
Dim last_cell As Integer
Dim platforms() As String
Dim arr_size As Integer
platforms = Split(Cells(2, 47), ", ")
last_cell = Mid(Range("A1048576").End(xlUp).Address, 4)
arr_size = len(platforms) // is there something like this?
For x = 1 To last_cell
For y = 1 To arr_size
//do something
Next
Next
End Sub
My question is, how may I get the array size(arr_size) that is returned by the split function, so that I could use in my for loop? Thank you.
Description. The Microsoft Excel SPLIT function will split a string into substrings based on a delimiter. The result is returned as an array of substrings. The SPLIT function is a built-in function in Excel that is categorized as a String/Text Function. It can be used as a VBA function (VBA) in Excel.
VBA Code to get the length of Array (one-dimensional array):Press Alt+F8 to popup macro window. Select ” oneDimArrayLength” and Click Run button. Compute Number of Rows, Number of Columns using UBound and LBound function. Multiply by noOfRow and noOfCol variable to get Number of elements in multi-dimensional array.
Step 1: Write the subprocedure for VBA Type Mismatch. Step 2: Again assign a new variable, let's say “A” as Byte data type. Let's understand the Byte Data type here. Byte can only store the numerical value from 0 to 255.
VBA LBound and UBound return the first and the last array position, so the correct answer is:
size = UBound(myArray) - LBound(myArray) + 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With