Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6726089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:53:07+00:00 2026-05-26T09:53:07+00:00

two questions, first can you remind me how to polulate a multidimensional array when

  • 0

two questions, first can you remind me how to polulate a multidimensional array when assigning it? I always do it with for loop and how to staticly do it seems to escape me?

But what I am really looking to do is to use the array to validate cells contents. however in the example below I want to use only the first element in the 2nd dimension.

ie
0,0
1,0
2,0
3,0
4,0

Is there any way to update the .Add Type:=xlValidateList, Formula1:=Join(ary, “,”) line so it only returns these 5 values from a 5 by 4 array?

Cheeers

aaron

Sub test()


Dim ary As Variant
ReDim ary(5,4)


ary = Array("Value1", "Value2", "Value3", "test", "test2", "test3", "test4")

With ActiveSheet.Cells(1, 1).Validation
    .Delete
    .Add Type:=xlValidateList, Formula1:=Join(ary, ",")
    .IgnoreBlank = False
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = ""
    .ShowInput = True
    .ShowError = True
End With
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:53:08+00:00Added an answer on May 26, 2026 at 9:53 am

    The resizing of a 2D array to 1D is quick

    The code below populates your 5*4 array with sample data, a second loop then extracts only the first dimension to a new 1D array withe the same row length as your initial array

    Sub test()
    
        Dim ary As Variant
        Dim X As Variant
        Dim lngRow As Long
        Dim lngCol As Long
    
        ReDim ary(1 To 5, 1 To 4)
        ReDim X(1 To UBound(ary, 1))
    
        For lngRow = 1 To UBound(ary, 1)
            For lngCol = 1 To UBound(ary, 2)
                ary(lngRow, lngCol) = "I am row " & lngRow & "  and dimension " & lngCol
            Next
        Next
    
        For lngRow = 1 To UBound(ary, 1)
        X(lngRow) = ary(lngRow, 1)
        Next
    
        With ActiveSheet.Cells(1, 1).Validation
            .Delete
            .Add Type:=xlValidateList, Formula1:=Join(X, ",")
            .IgnoreBlank = False
            .InCellDropdown = True
            .ShowInput = True
            .ShowError = True
        End With
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two questions. My first one is, that how can i put something
I develop my first application for WP7. I have two questions : How can
Hey everyone, I want to start using Scheme and I have two questions. First,
Two questions: Can someone point me to unbiased data that compares .NET performance to
Two questions: How can I import a file from a web address, without a
Two questions. First question is I'm trying to create a simple form that when
I feel a little embarassed posting two questions relating to the same problem, but
This is actually two questions in one: First, when you write your XAML and
I have two questions concerning fitting a gauss curve to histogram peaks. My first
Two questions about attributes: When are attribute classes instantiated? When the type is first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.