Consulting

Results 1 to 14 of 14

Thread: vlookup question

  1. #1
    VBAX Regular
    Joined
    Feb 2013
    Posts
    51
    Location

    Smile vlookup question

    Hi

    I'm just trying to do a variation of using vlookup. I want to take rows from the data table which are colored green only and then copy and paste the corresponding columns into the output columns starting in column H. I've already put the output manually to illustrate what I want. The vlookup code should go in column H I think.

    I have: vlookup(B2,$A$2:$E:$4,4,FALSE)

    I'm not sure how to specify that color cell in the first argument. Also I'm not sure about the 4 as in fact I need data copied to three columns.

    Any thoughts?
    Attached Files Attached Files

  2. #2
    I'm sure you can't do a vlookup on cell colours. You'll need to do this via VBA. With VBA you can locate the coloured cells, and then if you still wish generate the vlookup formula or you can just dump the data as values.

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Wouldn't it be easier to simply filter your data table to only show those rows where the B cell is Green?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    VBAX Regular
    Joined
    Feb 2013
    Posts
    51
    Location
    Quote Originally Posted by ashleyuk1984 View Post
    I'm sure you can't do a vlookup on cell colours. You'll need to do this via VBA. With VBA you can locate the coloured cells, and then if you still wish generate the vlookup formula or you can just dump the data as values.
    I was thinking of using an IF statement within the first argument. I'll have to wait until I get home from work to look through some VBA procedures in this case.

    Thanks

  5. #5
    VBAX Regular
    Joined
    Feb 2013
    Posts
    51
    Location
    Thanks that should be good. I'll get back if there are any further issues.

  6. #6
    VBAX Regular
    Joined
    May 2014
    Location
    Los Santos
    Posts
    18
    Location
    Someone mentioned using a filter on green rows; this would indeed work. The weakness is that if you wanted to say copy-paste the output result somewhere else, you'd still get the resutls from the non-green stuff, as using the filter just hides it, doesn't actually get rid of it. See my attached file. Filter is controlled via the drop down arrow above the colour column. No fancy vlookups required!
    Attached Files Attached Files

  7. #7
    Quote Originally Posted by OG Loc View Post
    Someone mentioned using a filter on green rows; this would indeed work. The weakness is that if you wanted to say copy-paste the output result somewhere else, you'd still get the resutls from the non-green stuff, as using the filter just hides it, doesn't actually get rid of it. See my attached file. Filter is controlled via the drop down arrow above the colour column. No fancy vlookups required!
    You are correct, but also incorrect if you know how to do it correctly
    Select the filtered cells... Press F5, Special, VISIBLE CELLS ONLY... Now you can copy and paste
    You're welcome

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Am I missing something here? The copy-paste of the filtered data does not copy the hidden rows, it only copies the visible data. Don't even need the F5 approach. At least on my machine that is how it happens.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    VBAX Regular
    Joined
    May 2014
    Location
    Los Santos
    Posts
    18
    Location
    Quote Originally Posted by xld View Post
    Am I missing something here? The copy-paste of the filtered data does not copy the hidden rows, it only copies the visible data. Don't even need the F5 approach. At least on my machine that is how it happens.
    I decided to double check, and it definitely does copy the hidden rows as well with an ordinary copy. It's possible that all your hidden rows were at the beginning or end of the data so that when you select the visible part, you are actually missing some of the table. If you make sure to select the whole thing by selecting cells beyond the bottom for good measure, I find that it does reveal the hidden parts when you paste is, using Excel 2010. I guess the other exception is if you are pasting it onto the same set of rows so that the relevant ones are already hidden.

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Oh come on, I am a bit better at Excel than that.

    I have tried all combinations, and it behaves as I describe.
    Attached Images Attached Images
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    VBAX Regular
    Joined
    May 2014
    Location
    Los Santos
    Posts
    18
    Location
    Quote Originally Posted by xld View Post
    I have tried all combinations, and it behaves as I describe.
    I have discovered the truth! In my spreadsheet I had the data in a table, while in yours it looks like it is just a range with a filter applied. Did another quick experiment and it seems they behave differently, as we have both described!

  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Guess what. Even tables behave properly for me, no hidden rows copied.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  13. #13
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Quote Originally Posted by xld View Post
    Guess what. Even tables behave properly for me, no hidden rows copied.
    Well, that's because they know whom they are dealing with
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  14. #14
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Paul_Hossler View Post
    Well, that's because they know whom they are dealing with
    Excel is very kind and gracious to me, that is why I love it

    Now Windows on the other hand, ...
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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