+ Reply to Thread
Results 1 to 5 of 5

Add a value to a specific cell using a hlookup and match formula

  1. #1
    Registered User
    Join Date
    06-22-2013
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Add a value to a specific cell using a hlookup and match formula

    Hi there,

    I'm very new to VBA and to the forum but I'm very keen to learn and I know I'm the right place to do so!

    With that in mind, I'm having issues writing code to update a specific cell with a value based on selections in a userform.

    What I have is a userform with a drop down box to select a person's name from and a date. On my worksheet I have the names of the people in column A and the dates in columns D to M. What I want to happen is when a user selects a persons name, I want it to update the corresponding cell based on the date with the letter "w".

    The code I have to find the corresponding cell is:
    Application.HLookup(Me.TextDate.Value, Sheets("Availability").Range("D1:M100").Value, Application.Match(Me.cboCandidateNames.Value, Sheets("Availability").Range("A1:A100").Value, 0), 0))

    and this works to find the correct cell but I'm not sure what I need to add in to make it change that cell to a "w".

    Any help would be much appreciated, thank you in advance!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Add a value to a specific cell using a hlookup and match formula

    Hello lnh2204,

    Welcome to the Forum!

    The macro below will find the name and then the date. The cell containing the date will be changed to "w". In VBA using Ranges and the Find method offer you a wide range of options in searching.

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 07-10-2013 at 06:48 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-22-2013
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Add a value to a specific cell using a hlookup and match formula

    Thank you for your response Leith,

    This nearly works, except the date that it is looking for is always in cells D1:M1 and the cell i want to change to a "w" will be in line with whichever row the candidate name is in, if that makes sense?

    That macro works if the date is in every cell in the column but i only want it to look at the date at the top.

    I guess what I really need it to do is look for the name in column A and the date in row 1. So if the name is in cell A3 and the date is in cell D1, the cell i need to have a "w" in is cell D3; if name is in cell A21, date in G1, "w" in cell G21 etc etc

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Add a value to a specific cell using a hlookup and match formula

    Hello lnh2204,

    A sample workbook would be a great help. Can you post one?

  5. #5
    Registered User
    Join Date
    06-22-2013
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Add a value to a specific cell using a hlookup and match formula

    I have attached an example of what the table looks like, I hope this is what you meant?
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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