+ Reply to Thread
Results 1 to 10 of 10

returning a string from an array when given 2 references

  1. #1
    Registered User
    Join Date
    08-07-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    21

    returning a string from an array when given 2 references

    I want to collect the string in row 1 when given a value in col 1 and a value that would exist in that row.
    For example if given a 4 for col 1 and a value of 10, I want the string 18-2 returned.
    The data in rows 2 thru 10 is self entered and can be changed if it would help.
    Many thanks for any help provided.

    asas.png

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: returning a string from an array when given 2 references

    How would you specify the 4 and where would your output go?
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    484

    Re: returning a string from an array when given 2 references

    With 4 in cell H1 and 10 in cell I1, try

    =INDEX(B1:F1,MATCH(TRUE,INDEX(ISNUMBER(FIND(","&I1&",",","&INDEX(B2:F10,MATCH(H1,A2:A10,0),0)&",")),0),0))

  4. #4
    Registered User
    Join Date
    08-07-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    21

    Re: returning a string from an array when given 2 references

    They are both variables.
    rank = 4
    points = 10
    result = 18-2

    all 3 are strings

    Thanks for looking

  5. #5
    Registered User
    Join Date
    08-07-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    21

    Re: returning a string from an array when given 2 references

    Thanks Root_

    Now I should be able to assign that to a var in VBA, correct ?

    ie var1 = index.........

  6. #6
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    484

    Re: returning a string from an array when given 2 references

    Not exactly.

    You would need var1 = [INDEX(...)]

  7. #7
    Registered User
    Join Date
    08-07-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    21

    Re: returning a string from an array when given 2 references

    asasas.png

    here is a pic of the sheet named DATA

    the VBA formula I am trying is pasted in row 20.

    the actual code is
    Private Sub Score_ComboBox_Change()
    Score_ComboBox.BackColor = &H80000005

    loser_balls_made = Score_ComboBox.Text

    'score change

    Splitpoints = [INDEX(poss_scores,MATCH(TRUE,INDEX(ISNUMBER(FIND(","&loser_balls_made&",",","&INDEX("&loser_points&",MATCH("&losers_rank&","&loser_rank&",0),0)&",")),0),0))]


    'my_points = Left(Points, 1)
    'opp_points = Right(Points, 1)
    'points_TextBox.Value = RetPts

    End Sub
    I am getting an error 2015

    Please help
    Thank you

  8. #8
    Registered User
    Join Date
    08-07-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    21

    Re: returning a string from an array when given 2 references

    I am getting an error 2015

    Please help
    Thank you

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: returning a string from an array when given 2 references

    Observation -- I notice that the working left to right across a given row, the numbers are continuously increasing, so that each column represents a range. For the "4" row, B is 0 to 5, C is 6 to 8, D is 9 to 11, and so on. Similar for each row, except that the boundary value between columns is different. Question -- Is this going to always be true?

    If so, then the solution I see is to enter only one value (the initial value) in each cell and use the "approximate match -- sorted ascending" option in Excel's MATCH() function. https://support.office.com/en-us/art...9-533f4a37673a

    In a simple worksheet formula (I don't know why VBA is needed or desired for this), this might look something like:
    row number: MATCH(4,$A$2:$A$10,1)
    column number: MATCH(10,INDEX($B$2:$F$10,result of row number,0),1) -- recall from help file how INDEX() behaves when row or column # is 0 (it returns the entire column/row https://support.office.com/en-us/art...2-b56b061328bd ).
    final result: =INDEX($B$1:$F$1,result of column number).

    If there is a reason this wants to be done in VBA, use the same approach using the application.worksheetfunction object to access these functions in Excel's function library https://msdn.microsoft.com/en-us/vba...n-visual-basic

    will that work for you?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  10. #10
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    484

    Re: returning a string from an array when given 2 references

    See if this works for you
    Please Login or Register  to view this content.
    P.S.: I have removed the inner INDEX. It was used to make the formula in Post # 3 "normal-entered" (i.e., non-array).

+ 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. VBA to change indirect references to direct references within array formulas
    By acj06 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2017, 12:16 AM
  2. [SOLVED] FIND Function; looking for an array of strings and returning found string value
    By loloduane in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-05-2014, 04:11 AM
  3. VBA Find Partial String in String Array and Output the Found String Array Value
    By scherich in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2014, 11:20 AM
  4. Replies: 4
    Last Post: 12-23-2013, 08:43 AM
  5. [SOLVED] Return matching string in array if cell contains string contained in the array
    By AaronsZ in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-03-2013, 01:55 PM
  6. Dissecting a formula string into references/non-references
    By quekbc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-06-2011, 10:52 AM
  7. Macro returning string, while i want array
    By DanceFanatic707 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2010, 02:57 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