+ Reply to Thread
Results 1 to 16 of 16

Code to Search a table for a specific Cell and fill it

  1. #1
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Code to Search a table for a specific Cell and fill it

    Hi All,

    I need a VBA code to work with my Userform:

    The code needs to search a sheet "Tabelle2" for a specific Column in Row 1 and a specific Row in Column A and where they cros Fill the Cell with Specific Data.

    So if i had dates in Column A and Names in Row 1 it would search for the date and name and where they cross would insert a text from the userform.

    Any help would be appreciated.

    Regards

    Jeremy
    Last edited by JRidge; 07-04-2014 at 06:38 AM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to Search a table for a specific Cell and fill it

    Hi Jeremy ,

    What are the specs?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Code to Search a table for a specific Cell and fill it

    Hi xladept,

    Basically i have a UserForm with text boxes that the user fills out, When he presses "Save" the code should search for the key words in Row1 and then go down the coloumns to the appropiate dates (Dates all in ColumnA, Where the dates and Keywords cross in the Table it will insert what ever is in the "Tatigkeits" Textbox, i.e "IB" for example.

    There could be multiple Dates in the Userform because the user selects a start and end Date, So all dates between start and end date need to be filled aswell. There could be Multiple Keywords also in Row1. So all the cells that meet this criteria need to be filled.

    Boxes in userform are:

    Kunde (Combobox) - will always be a Keyword in Row1
    VonDatum (Textbox) - Start date always in ColumnA
    ZuDatum (Textbox) - End date always in ColumnA
    Mitarbeiter1 (Combobox) - Will always be a keyword in Row1
    Mitarbeiter2 (Combobox) - Will always be a keyword in Row1
    Mitarbeiter3 (Combobox) - Will always be a Keyword in Row1
    Tatikeit (Textbox) - This needs to be inserted in all cells that meet the criteria above.


    Phew...

    Does that make sense...

    Regards

    Jeremy
    Last edited by JRidge; 06-27-2014 at 03:08 AM.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to Search a table for a specific Cell and fill it

    Hi Jeremy,

    You'd best post a sample workbook as your chances on getting help will increase dramatically.

  5. #5
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Code to Search a table for a specific Cell and fill it

    So this works for search one of the 1 of the criteria:

    Searching for Kunde i Row and singel Date in Column:

    Please Login or Register  to view this content.
    It put the name in "Tatigkeit" in the correct cell:

    As soon as i say search what is in "VonDatum" it no longer puts anything in the cell, "VonDatum" is the textbox on the userform when the date is inputed above...

    Please Login or Register  to view this content.
    Cheers for any help

    Jeremy
    Last edited by JRidge; 06-30-2014 at 04:42 AM.

  6. #6
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Code to Search a table for a specific Cell and fill it

    Slowly getting there...

    I can now use the text boxes to search and it fills the 2 relevent Cells.... From Date and To Date:

    Please Login or Register  to view this content.
    Is there away to join these together so it fills the start date box, the end date box and all dates in the middle... (Do i need to use looping??)

    And what would it look like?

    Any Help would be greatly appreciated.

    regards

    Jeremy

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to Search a table for a specific Cell and fill it

    Probably:

    Please Login or Register  to view this content.
    Last edited by xladept; 06-30-2014 at 03:19 PM.

  8. #8
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Code to Search a table for a specific Cell and fill it

    Hi xladept,

    Thank you for your help, I have come up with this that works (Of cause with help from other members etc, ty Norie)

    Please Login or Register  to view this content.
    I need to now work out how to also change the background color of the affected cells at the same time?

    Any ideas??

    Regards

    Jeremy

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to Search a table for a specific Cell and fill it

    Maybe:

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Code to Search a table for a specific Cell and fill it

    Quote Originally Posted by xladept View Post
    Maybe:

    Please Login or Register  to view this content.
    Is there anyway to use the background color of a textbox in a userform instead of selecting the color in the code.

    Example,

    TextBox is called TextBox1, When i click save it uses the color that is currently in the textbox as background color?

    Thought something like

    Please Login or Register  to view this content.
    But that doesn't work,

    Any Ideas

    Regards

    Jeremy

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to Search a table for a specific Cell and fill it

    How is the textbox color assigned? Is it conditional formatting or rgb or what - because apparently it isn't colorindex?

  12. #12
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Code to Search a table for a specific Cell and fill it

    Hi xladept,

    Currently it is :

    Please Login or Register  to view this content.
    And looks like:

    Text Box.PNG

    You click the color you want and it fill the text box

    Dont know if this is the best way of doing it.

    Regards

    Jeremy

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to Search a table for a specific Cell and fill it

    Maybe:

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Code to Search a table for a specific Cell and fill it

    Thanks xladept,

    Does just what i need.

    Will check it prooerly when i am in the office in a bit, and let you know.

    Regards

    Jeremy

  15. #15
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: Code to Search a table for a specific Cell and fill it

    Hi xladept,

    Thanks for your help on this works perfectly,

    I have opened a new thread in this forum, could you have a look please

    HTML Code: 
    Regards

    Jeremy

  16. #16
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to Search a table for a specific Cell and fill it

    You're welcome and thanks for the rep!

    *I'll take a look.

+ 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. Help with VBA code to find bottom row in pivot table and fill table cell borders
    By Eric111 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-28-2014, 07:15 PM
  2. Replies: 4
    Last Post: 08-15-2013, 09:50 AM
  3. VBA code to search a list for specific value
    By PonyKiller87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-29-2013, 03:50 PM
  4. Replies: 0
    Last Post: 08-20-2010, 09:01 AM
  5. [SOLVED] Search for a number in a table and return data of a specific cell
    By Karaman in forum Excel General
    Replies: 4
    Last Post: 06-30-2006, 10:50 AM

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