+ Reply to Thread
Results 1 to 6 of 6

Switch an array within udf function into a range

Hybrid View

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Switch an array within udf function into a range

    Hello everybody
    I have udf function in my attachment .. from which I can extract the gender , the date of birth and governorate according to 14 digits as illustrated in the attachment
    I need to do without the array named (MyProvinces) used in the function and use a specific range as in sheets("Data").range("A2:B5")
    Attached Files Attached Files

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,982

    Re: Switch an array within udf function into a range

    Why use a UDF at all? INDEX and MATCH would be as easy and faster.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Switch an array within udf function into a range

    Thanks for reply
    I need to know how to convert an array in vba to a range of that array in worksheet

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,391

    Re: Switch an array within udf function into a range

    This is probably a good place to start: http://www.cpearson.com/excel/ArraysAndRanges.aspx

    The complication I see with your MyProvinces array is that currently, each element of the array is a "concatenation" of the ID# & province# text string. If you feel it is necessary to structure the myprovinces array in this way, you will probably need to create the array in a loop
    untested pseudocode
    For i=1 to number of provinces
    myprovinces(i)=i & columnD.cells(i,1).value
    next i
    rest of code to complete task.
    I personally would tend to use a 2D array for something like this. Something where myprovinces(1,1)=01, myprovinces(1,2)="Cairo" and so on, rather than concatenate those two pieces of information together. Not sure it is better, but I find it easier to use each element of the array if there is only one piece of information in each element.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Switch an array within udf function into a range

    Thanks Mr. Shorty
    I accept cD array , but in fact I'm not good at arrays at all.
    Can you do it for me, please?

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,391

    Re: Switch an array within udf function into a range

    I'm not really a "do it for you" kind of user on this board. I also am probably not the best choice to do it because, like romperstomper, I would probably do it by worksheet formula rather than VBA. But, I observe from your other postings on here that you have a strong preference for VBA solutions rather than worksheet formula solutions, so I guess it is what it is.

    I might suggest that there is no time like the present to become more skilled at using arrays. What kinds of things do you not understand? How to dimension arrays? How to load arrays? How to read from the array? Or perhaps you are more uncertain about the different loop structures (because they tend to be important when working with arrays).

    I don't know if you reviewed chip pearson's page that I linked to earlier. If needed you might look at a more introductory page like: http://www.classanytime.com/mis333k/sjloopsarrays.html or put "introduction to arrays in VBA" into your favorite internet search engine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Array Function to shift rows to the right in a range
    By aab_489 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-09-2014, 07:02 AM
  2. Excel: Creating Search with Switch Columns using array formula
    By hwatson86 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-03-2012, 05:08 AM
  3. Use toggel button to switch the content of an array of cells
    By deepakya3 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-08-2011, 07:52 AM
  4. Read Range To Array, Then Pass Array To Function
    By ProbablyNotARealName in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-20-2010, 12:29 PM
  5. [SOLVED] Switch function
    By kramer.newsreader@gmail.com in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-16-2006, 05:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1