What Is UBound And LBound
Jan 7, 2013could not find a satisfactory explanation UBound and LBound functions.
View 2 Repliescould not find a satisfactory explanation UBound and LBound functions.
View 2 RepliesI have set up a worksheet to demonstrate how arrays work--and find that I need to learn more about the topic myself! The code below reads data from Column A into an array, sorts it, and then writes the sorted data to Column B. In the example I have created there are 11 data values in Column A. When I break at the indicated line of code, I find that LBound(sourceData) = 1 and UBound(sourceData) = 11, as expected. However, at the indicated line of of code, when i = 1, the reference to sourceData(i) results in a subscript error.
Public Sub AddSortedColumn()
Dim sourceData() As Variant
sourceData = Range("A1:A" & Range("A65536").End(xlUp).Row)
Dim swap As Boolean
Dim i As Integer
Dim save As Variant
swap = True
Do While swap
swap = False
For i = LBound(sourceData) To UBound(sourceData) - 1..................
How to calculate the size of an input variant using UBound? Sometimes I need to do the transpose but sometimes I don't. I tried ON ERROR GOTO but it doesn't work in this case. Can you tell me how I could do that?
Public Function Shock(A_E As Variant, Year As Variant) As Double
Dim n As Integer
n = UBound(A_E,1)
Shock = n
End Function
This is the first portion of my code. When it reaches x1, it dies... I put in a break... when I highlight that line, it displays:
UBound(myArray1, 1) =
Public Function M_ADD(myArray1, myArray2)
Dim i As Integer, j As Integer
Dim x1 As Long, x2 As Long
Dim y1 As Long, y2 As Long
If VarType(myArray1) >= vbArray Then
x1 = UBound(myArray1, 1) '
My question is about using UBound with an array of User-Defined Data Type. I don't know how to use UBound to find the total elements in the following arrays called MealItem()
View 3 Replies View Related