Number of elements in a single dimension variant array in excel

0 votes

Is This code correct for determining the number of elements in a single dimension variant array in Excel VBA. Supposing I have a variant array named Array1 with k elements.

Dim n as Integer
n = UBound(Array1)

Mar 23 in Database by Edureka
• 13,640 points
64 views

1 answer to this question.

0 votes

You must do UBound - LBound + 1 to acquire an accurate count. This is due to the fact that arrays do not have to begin at index 1 and end at index n; they can begin at any index. Here's an example where the number of pieces increases from 3 to 7, totaling 5 (3, 4, 5, 6, and 7):

Sub tgr()

    Dim Array1(3 To 7) As Variant
    Dim lNumElements As Long

    lNumElements = UBound(Array1) - LBound(Array1) + 1
    MsgBox lNumElements

End Sub
answered Mar 24 by gaurav
• 13,560 points

Related Questions In Database

0 votes
1 answer

Query to list number of records in each table in a database

Use the below code to list number of ...READ MORE

answered Oct 11, 2019 in Database by Omaiz
• 560 points
655 views
0 votes
1 answer

How to enter a series of numbers automatically in Excel

Excel, unlike other Microsoft Office programmes, does ...READ MORE

answered Apr 4 in Database by Edureka
• 13,640 points
25 views
0 votes
0 answers

How to split a string of text in excel based on a given word?

I have a list of combinations of ...READ MORE

Apr 4 in Database by gaurav
• 13,560 points
49 views
0 votes
1 answer

Maximum number of rows of CSV data in excel sheet

The maximum number of characters per cell ...READ MORE

answered Apr 6 in Database by gaurav
• 13,560 points
477 views
0 votes
1 answer

Pasting an Excel range into an email as a picture

Hold down the ALT + F11 keys ...READ MORE

answered Mar 30 in Database by gaurav
• 13,560 points
94 views
0 votes
1 answer

#NAME? error in Excel for VBA Function

Because you have a module with the ...READ MORE

answered Apr 5 in Database by gaurav
• 13,560 points
53 views
0 votes
1 answer

Excel vba for loop

You must understand how to use loops ...READ MORE

answered Apr 5 in Database by gaurav
• 13,560 points
70 views
0 votes
0 answers

Unprotect workbook without password

I have a popular VBA code to ...READ MORE

Apr 7 in Database by Edureka
• 13,640 points
28 views
0 votes
1 answer

Convert a number to a letter in C# for use in Microsoft Excel [duplicate]

If you are familiar with using formulas ...READ MORE

answered Feb 23 in Database by gaurav
• 13,560 points
44 views
0 votes
1 answer

How can I calculate deciles with a range of 12,000 cells in excel?

1. Enter the following formula in cell ...READ MORE

answered Mar 25 in Database by gaurav
• 13,560 points
139 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP