+ Reply to Thread
Results 1 to 11 of 11

macro to copy data where the ID is equal to what is copied from another cell

  1. #1
    Registered User
    Join Date
    09-23-2010
    Location
    Guildford, England
    MS-Off Ver
    Excel 2003
    Posts
    10

    macro to copy data where the ID is equal to what is copied from another cell

    Hey there
    Is it possible to get a macro that does a sort of v lookup funtion from a table in another sheet, i cant use v lookup as it has to be copied and pasted by the macro so that if the data isnt in the table it can be manually entered

    If anyone can help it will be much appriciated.

    Thanks,

    Blink359

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: macro to copy data where the ID is equal to what is copied from another cell

    Here's something that may get you started. It uses the vlookup function and checks to see if the value was found. I've made the example so that it just displays a message if it is not found, but you could modify it to ask for a value.
    Please Login or Register  to view this content.
    Bob
    Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.

  3. #3
    Registered User
    Join Date
    09-23-2010
    Location
    Guildford, England
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: macro to copy data where the ID is equal to what is copied from another cell

    Hey is it possible to use the macro you made and combine it with this:
    Please Login or Register  to view this content.
    so that it does the vlookup in the cells when it can find the number and does the pop up message from the bottem of your macro when it cant find the ID

    Thanks,

    Blink359

  4. #4
    Registered User
    Join Date
    09-23-2010
    Location
    Guildford, England
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: macro to copy data where the ID is equal to what is copied from another cell

    Bump - still need help :S

  5. #5
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: macro to copy data where the ID is equal to what is copied from another cell

    Soory for the delay. I was out of town. The approach that you want to take will only generate NA is the cells and you will be not able to capture them. Do you want to display a message after each vlookup?

  6. #6
    Registered User
    Join Date
    09-23-2010
    Location
    Guildford, England
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: macro to copy data where the ID is equal to what is copied from another cell

    I was hoping to have a little table that has a ID that it looks up in the table and returns the rest of the information in the cells i.e |ID|Name|Surname|Age| and if it could find the id it would do a vlookup from existing customers table and return the information in the cells, If that cant be done is it possible to do a check box that changes the visibility of a button and turns a cell validation on/off, I have tried other things such as auto filter by copying the id of the cell but that didnt work either. Im not quite sure what else to do.

  7. #7
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: macro to copy data where the ID is equal to what is copied from another cell

    Could you attach a workbook showing inputs and desired outputs. That would help us understand what you want a bit better. Don't include any sensitive data.

  8. #8
    Registered User
    Join Date
    09-23-2010
    Location
    Guildford, England
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: macro to copy data where the ID is equal to what is copied from another cell

    Here you go sheet "Invoice" and "Existing Customers" are the ones the macro needs to use
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: macro to copy data where the ID is equal to what is copied from another cell

    Quote Originally Posted by blink359 View Post
    If that cant be done is it possible to do a check box that changes the visibility of a button and turns a cell validation on/off, I have tried other things such as auto filter by copying the id of the cell but that didnt work either. Im not quite sure what else to do.
    I'm getting closer to understanding this, but need to be a bit of clarification. I understand that if the customer ID is found, then the rest of the fields need to be updated. What is supposed to go in G18 in this case?

    I have made an update to the VBA for the Inventory sheet, putting a WorkSheet_Change event handler. If the number number is changed in cell b15, then the existing customers is searched and the fields updated. If the customer is not found, then G18 is set to "Not Found".

    I am not sure about what you want with the button and data validation. Let me know if what I sent you is close and we'll go from there.

    I also had to comment out a coupld of lines in teh modules to get this to compile.Example.xlsm

  10. #10
    Registered User
    Join Date
    09-23-2010
    Location
    Guildford, England
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: macro to copy data where the ID is equal to what is copied from another cell

    Hey, Thanks ever so much dont wory about the validartion thing i was trying to think of more than one solution to the problem. Just so i get something out of this can you explain/link any tutorials to what you did so i can understand it myself?

    Thanks again,

    Blink359

  11. #11
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: macro to copy data where the ID is equal to what is copied from another cell

    There are many ways to learn VBA and I don't know what suits you best. There are many tutorials on Microsoft's MSDN web site. Here is one example. You can also use the VBA help to see what an individual sollction, object, property, method, or event handler does, either by searching on the name, or put the cursor in the word in the code and pressing F1. Hope this helps a little.

+ 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