+ Reply to Thread
Results 1 to 5 of 5

Lookup in VBA Array

  1. #1
    ExcelMonkey
    Guest

    Lookup in VBA Array

    I have a 2D array with text strings (sheet names) in
    column 1 and boolean values (1 or 0) in column 2. I want
    to be able to do a lookup of the boolean values for each
    sheet within the sheet name array while in a For Each
    Loop.The idea being that I will do search based on name
    propterty of the sheet that I am looping through.

    For each Sh in Workbook
    Lookup boolean in column 2 of SheetName Array based on
    sh.Name
    Next

    Not sure how to use lookups in VBA

  2. #2
    Don Guillett
    Guest

    Re: Lookup in VBA Array

    You might like vba FIND better. Look in the HELP index.

    --
    Don Guillett
    SalesAid Software
    donaldb@281.com
    "ExcelMonkey" <anonymous@discussions.microsoft.com> wrote in message
    news:19c301c50f98$9e427bd0$a601280a@phx.gbl...
    > I have a 2D array with text strings (sheet names) in
    > column 1 and boolean values (1 or 0) in column 2. I want
    > to be able to do a lookup of the boolean values for each
    > sheet within the sheet name array while in a For Each
    > Loop.The idea being that I will do search based on name
    > propterty of the sheet that I am looping through.
    >
    > For each Sh in Workbook
    > Lookup boolean in column 2 of SheetName Array based on
    > sh.Name
    > Next
    >
    > Not sure how to use lookups in VBA




  3. #3
    Tom Ogilvy
    Guest

    Re: Lookup in VBA Array

    Find doesn't work with arrays.

    --
    Regards,
    Tom Ogilvy

    "Don Guillett" <donaldb@281.com> wrote in message
    news:evowR35DFHA.1836@tk2msftngp13.phx.gbl...
    > You might like vba FIND better. Look in the HELP index.
    >
    > --
    > Don Guillett
    > SalesAid Software
    > donaldb@281.com
    > "ExcelMonkey" <anonymous@discussions.microsoft.com> wrote in message
    > news:19c301c50f98$9e427bd0$a601280a@phx.gbl...
    > > I have a 2D array with text strings (sheet names) in
    > > column 1 and boolean values (1 or 0) in column 2. I want
    > > to be able to do a lookup of the boolean values for each
    > > sheet within the sheet name array while in a For Each
    > > Loop.The idea being that I will do search based on name
    > > propterty of the sheet that I am looping through.
    > >
    > > For each Sh in Workbook
    > > Lookup boolean in column 2 of SheetName Array based on
    > > sh.Name
    > > Next
    > >
    > > Not sure how to use lookups in VBA

    >
    >




  4. #4
    Jim Rech
    Guest

    Re: Lookup in VBA Array

    An example of a lookup:

    Result = Application.VLookup(ActiveSheet.Name, _
    Sheet1.Range("A1:B10"), 2, False)


    --
    Jim Rech
    Excel MVP
    "ExcelMonkey" <anonymous@discussions.microsoft.com> wrote in message
    news:19c301c50f98$9e427bd0$a601280a@phx.gbl...
    |I have a 2D array with text strings (sheet names) in
    | column 1 and boolean values (1 or 0) in column 2. I want
    | to be able to do a lookup of the boolean values for each
    | sheet within the sheet name array while in a For Each
    | Loop.The idea being that I will do search based on name
    | propterty of the sheet that I am looping through.
    |
    | For each Sh in Workbook
    | Lookup boolean in column 2 of SheetName Array based on
    | sh.Name
    | Next
    |
    | Not sure how to use lookups in VBA



  5. #5
    Tom Ogilvy
    Guest

    Re: Lookup in VBA Array

    Dim Res as Variant
    Dim Sh as Worksheet
    Dim bRes as Boolean
    For each Sh in Workbook
    Res = Application.VLookup(sh.Name, SheetName,2,0)
    if not iserror(Res) then
    bRes = Res

    end if

    Next


    --
    Regards,
    Tom Ogilvy



    "ExcelMonkey" <anonymous@discussions.microsoft.com> wrote in message
    news:19c301c50f98$9e427bd0$a601280a@phx.gbl...
    > I have a 2D array with text strings (sheet names) in
    > column 1 and boolean values (1 or 0) in column 2. I want
    > to be able to do a lookup of the boolean values for each
    > sheet within the sheet name array while in a For Each
    > Loop.The idea being that I will do search based on name
    > propterty of the sheet that I am looping through.
    >
    > For each Sh in Workbook
    > Lookup boolean in column 2 of SheetName Array based on
    > sh.Name
    > Next
    >
    > Not sure how to use lookups in VBA




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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