+ Reply to Thread
Results 1 to 8 of 8

VBA to Copy & Paste Data dependant on selection in a Data Validation List

  1. #1
    Registered User
    Join Date
    08-06-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    14

    VBA to Copy & Paste Data dependant on selection in a Data Validation List

    Hi Ladies and Gentleman,
    I am hoping someone here is able to give me the assistance I need. I am new to VBA in the sense that I have used quite a few Macros effectively through copying and pasting them from other threads and trying to modify to suit my situations, but I am still unfamiliar with the whole "VBA Language" itself. I am learning on the go.

    My Question is: I have two worksheets.
    "DETAILS" & "REFERENCES"
    The "REFERENCES" sheet contains all of the information I wish to reference with future macros.
    On the "DETAILS" sheet I have a column A-H merged into one. The cells in this column contain Data validation providing a drop down list of options linked back to "REFERENCES" BK:BR - (Also Merged in one column)

    What I am trying to achieve
    When I select from the list on the "DETAILS" sheet, I would like my macro to find the exact match on the "REFERENCES" sheet and copy all 78 cells to the right of that and paste them back next to the original list selection on "DETAILS" sheet?
    Is that confusing????? Hope not.

    I wonder if there is a need to clear the current contents before pasting the new cells also?

    As I plan to evolve this spreadsheet over time, I think all of my formatting should be done on the "REFERENCES" sheet and copied across exactly as is.

    Thanks in advance...... I'm new to this forum so I am happy to accept any advice on forum etiquette as well as VBA along the way. Your patience is appreciated.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA to Copy & Paste Data dependant on selection in a Data Validation List

    Hi Clinno,

    1) Post a sample workbook
    2) Doing according to your requirements will involve a change event macro on DETAILS sheet. Meaning, if the workbook location is not trusted, you will be prompted every time you open the workbook, to enable macros. Not really recommended if you intend to share the workbook.
    3) Or, you can do the formula way, filling formulae across the 78 cells. VLookUp should be sufficient.
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    08-06-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    14

    Re: VBA to Copy & Paste Data dependant on selection in a Data Validation List

    Thanks for the reply:
    This file will be shared in the sense that everyone opens up the template from a network location and saves their own individual copy to modify as required (also to a network location).
    We save all of our workbooks as macro enabled and our network location is listed as a trusted site with our anti-virus software.
    Hopefully that is what you are talking about. I would prefer to use a macro rather than formulas.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-06-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    14

    Re: VBA to Copy & Paste Data dependant on selection in a Data Validation List

    Once you see my workbook, feel free to ask more questions with regards to what I am trying to achieve here.

  5. #5
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA to Copy & Paste Data dependant on selection in a Data Validation List

    See if this works how you wanted?

    Below code is added to DETAILS sheet. I also removed some of the modules which were empty.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-06-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    14

    Re: VBA to Copy & Paste Data dependant on selection in a Data Validation List

    Thanks millz, this is definitely very close to what I'm after!!! On first instance it seems to work well. I need some time to tweak a few things with it but will be back to quiz you as soon as I can with some follow up Questions regarding this macro. Just a bit busy currently doing something else.

  7. #7
    Registered User
    Join Date
    08-06-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    14

    Re: VBA to Copy & Paste Data dependant on selection in a Data Validation List

    Sorry for the delay..... I have attached the latest version of my Spreadsheet.
    I have made some changes and after hours of fumbling around I have given up and come running back for help.
    You'll notice in my "References" Worksheet that I have added some more named ranges that I would like to refer back to with my data validation lists on the "Details" worksheet.
    I was aiming to get them to work in the same fashion as shown in previous communication.
    The problem is that I simply don't understand enough about macros yet to get it working.
    I have attempted to tweak your existing macro and make it into 3 macros, but now they don't function when the workbook changes.
    I know its something to do with the SUB name being different???
    Attached Files Attached Files

  8. #8
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA to Copy & Paste Data dependant on selection in a Data Validation List

    Hi Clinno, you're right that the problem lies with the Sub name being different.

    The sub name Worksheet_Change is a Change event macro that is fired automatically by Excel, whenever you make changes to that worksheet containing the code. If you change this name to one that you want, Excel wouldn't know what code to run, unless you make another Change event macro, checks what is changed, and call your own macro with Call YourMacro()

    There were also some minor mistakes with the range columns, I have already amended them. Try this out.
    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)

Similar Threads

  1. Replies: 3
    Last Post: 06-04-2015, 02:27 PM
  2. Data Validation drop down list (Dependant
    By Willows59 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-11-2014, 06:38 AM
  3. Dependant ActiveX Combo Box list based on Data Validation List
    By spalmer28 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-12-2014, 07:57 AM
  4. [SOLVED] Data Validation : 2 Lists dependant on selection with vlookup for 3rd value
    By scwillyb in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-26-2014, 02:25 PM
  5. Data Validation Dependant auto update the list
    By Rocky2013 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2012, 07:38 PM
  6. How to use data validation for Mutiple lists dependant on one list
    By excel66 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-12-2011, 02:21 AM
  7. Dependant Data Validation List
    By Stabilos in forum Excel General
    Replies: 1
    Last Post: 11-21-2005, 01:50 PM

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