What Is UBound And LBound

Jan 7, 2013

could not find a satisfactory explanation UBound and LBound functions.

View 2 Replies


ADVERTISEMENT

Inexplicable Subscript: Find That LBound(sourceData) = 1 And UBound(sourceData) = 11, As Expected

Apr 20, 2007

I 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..................

View 5 Replies View Related

Size Of Array - Ubound

Mar 23, 2007

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

View 9 Replies View Related

UBound Array - Type Mismatch

Jan 27, 2009

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) '

View 9 Replies View Related

UBound With Arrays Of User-Defined DataTypes

May 1, 2009

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







Copyrights 2005-15 www.BigResource.com, All rights reserved