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

  • Home
  • SEARCH
  • 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 8478215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:41:05+00:00 2026-06-10T18:41:05+00:00

I have a large chunk of code that manually defines each element of an

  • 0

I have a large chunk of code that manually defines each element of an array for me that is annoyingly long and positioned at the beginning of one of my functions. I would like to hide the code or set it somewhere else WITHOUT changing its current meaning in any way if possible. I would like to avoid making the array global. It’s also not reasonable to pass the array from all the places that the function is called.

Is there some way to simply have the code sit somewhere else while VBA sees it as being a part of the function, i.e. as if I had all the elements defined at the beginning of the function? I imagine having some sort of “Sub” that’s not actually a Sub (I might call it an “Excerpt”) of code with the elements populated there with a single line in the function that calls the “Excerpt” by name.

  • 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-06-10T18:41:06+00:00Added an answer on June 10, 2026 at 6:41 pm

    You can return an array from a function so it could be in a module on its own;

    public Function getArr() as string()
        Dim arr(10) as string
        ...
        arr(5) = "Cakey"
        getArr = arr
    End Function
    

    Called with

    Dim arry() as string: arry = getArr()
    msgbox arry(5)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather large chunk of code that breaks sometimes, as far as
I have a fairly large chunk of code that produces/returns an arraylist of search
I have a large chunk of legacy php code that I need to interface
I have this simple code that needs to get a chunk of a large
I have some large chunk of data that I want to send to the
I have a process that (at night) takes a large chunk of data in
I have the following chunk of Python code (running v2.7) that results in MemoryError
I have a mildly large function (about 80 lines of code without comments) that
I have this string containing a large chunk of html and am trying to
I have a server application that, in rare occasions, can allocate large chunks of

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.