lookup multiple records with one criteria

  • Then change the following line of code:


    rngDataOut.entirerow = rngData.Entirerow.Value



    to this



    rngDataOut.Range("G1:IV1") = rngData.Range("G1:IV1").Value



    This should only return the columns of data that you want.




    Regards,
    Barry



    I'm not sure anybody here would say that learning VB was easy, unless they had previous programming experience, but it is rewarding. Just be patient and step through the code, and if there is a line of code that you don't understand ask what it does. However, in my case I didn't have access to this forum when I first learned VB/VBA everything that I learned came via recording macros. I found recording macros useful because I knew the actions that I performed and then could trace my steps in the recorded code. So one of my suggestions to people who want to expand their knowledge of macros ( VB/VBA ) is to first record, record, record macros. Everything else, by that I mean all the neat gee whiz stuff you see on this forum, will come in time. But as the saying goes you must learn to crawl before you walk. This forum though has helped me to keep from stumbling so much.



    Regards,
    Barry

  • Softly softly, catchy monkey . . .


    Barry,


    Thanks for your response - AGAIN!


    Slowly but surely I'm getting closer and closer to achieving my goal with this. I hope you'll bear with me while I'm on this learning curve.


    I implemented your latest amendment and it does indeed only pull the desired columns, however, I would like columns H through to O from the database to be displayed in columns A through to H in the display page. Could you show me how to specify the destination range in this code, please?


    Thanks very much,


    Paul.

    Paul.

  • Then change the following line of code:


    rngDataOut.Range("G1:IV1") = rngData.Range("G1:IV1").Value



    to this



    rngDataOut.Range("A1:H1") = rngData.Range("H1:O1").Value


    Regards,

  • Hmmm, that's very annoying! I tried several modifications of my own before I posted the last of my requests for help, and I could have sworn that the solution you provided was one of them. It couldn't have been though as I just did it and it worked. STRANGE!


    I did try modifying it myself - HONEST!


    Thanks again Barry.

    Paul.

  • Hmmmm?????



    Kind of makes you hopping mad don't it. I guess you do have a good screen name????????



    lol



    Regards,
    Barry

  • Not quite sure how to describe "hmmm". It's kind of a ponderous sound made while exhaling through the nose. My god, it's definitely far too late for me to be on here! How can I tell? Because I'm attempting to explain sound effects that occur when I'm Excelling! I really must sleep . . . I'm going slightly mad! No, strike that, I am totally mad! (this one's for Pesky Weasel) I'm madder than Mad Jack McMad, winner of last years's Mr Madman competition (courtesy of E Blackadder).


    I have to be up at 04:30 (BST) so I REALLY need to sleep. Thanks again for all the help I've received on this one. I could yet be back for more.


    Paul.

    Paul.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!