+ Reply to Thread
Results 1 to 20 of 20

Cope data from another sheet based on cell criteria

  1. #1
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Cope data from another sheet based on cell criteria

    Sheet 1 contains some person date (name, address etc) and a study they are involved in is in row C.

    First Name Surname Study
    Stuart Jones X
    Jess Jones Y

    I have 2 sheets named 'x' and 'y'

    I have this code which i can put into sheet 'x' and it will pull all the information from my data sheet for anyone who has 'x' in row C. In this case, Stuart Jones.

    I can also put the code into sheet 'Y' and it will do the same thing - no problems there. However i would like to modify this code to be able to run it on all sheets at the same time; the trick being the sheet value MUST be the same as the sheet name. My code only works on active worksheets, which isn't ideal.

    Can anyone help me?

    Please Login or Register  to view this content.
    Many thanks
    Stuart

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,484

    Re: Cope data from another sheet based on cell criteria

    Hi Stuart

    Perhaps something like this.... if I understand correctly, the Study is the sheet.name...Right...range being column C
    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    Hi Sintek,
    It seems to do something but it's not pulling the data - oddly it seems to randomly colour fill some cells in the sheets that have data to pull.

    I know i said the range column would be C but that's changed to H so i made some changes - maybe i've missed something?
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    Actually, scrap my last comment. I tried it again and it worked perfectly!!

    Thanks for the help!

    Stuart

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,484

    Re: Cope data from another sheet based on cell criteria

    Can only see once you upload a sample workbook of your scenario....This code was written as per my supposed sample.

    edited:
    Actually, scrap my last comment. I tried it again and it worked perfectly!!
    Glad you got it sorted...

  6. #6
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    I may have jumped the gun a little. It's not quite working every time. If i run it from my 'home' tab it doesn't work (i get that formatting issue) but if i run it from a study tab it works fine.

    I don't seem to be able to upload my file...
    Untitled.png

    but i can upload it to google drive: https://drive.google.com/open?id=0B6...1JBTU9PYldsdE0

    Let me know if you have any questions

    Stuart

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,739

    Re: Cope data from another sheet based on cell criteria

    The paperclip icon no longer functions. To attach a sample workbook click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  8. #8
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    Thank you - Here's my attachment
    Attached Files Attached Files

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,484

    Re: Cope data from another sheet based on cell criteria

    I don't understand....Where do you want to put the code....And from which sheet do you want to run it....
    Put
    Please Login or Register  to view this content.
    before
    Please Login or Register  to view this content.
    and then run from any sheet

  10. #10
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    I will either create a button on the home page or have it run when i add a new patient.
    So the active sheet will be the 'Home' sheet - i need it to run on all the other sheets without having to go into each sheet.

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,484

    Re: Cope data from another sheet based on cell criteria

    i need it to run on all the other sheets without having to go into each sheet.
    The code is written to take info from sheets("Patientlist") and copy to appropriate patient Sheet....
    What do you want the code to do?

  12. #12
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    Okay, so when i use my add patient form from the home screen it will add the patient details to the 'patientlist' sheet, including a Study id which is populated in column H of 'patientlist'.

    Now, each of the study sheets, such as 'annexa4' needs to stay updated with all patients that are registered on this study - it will pull all rows where 'annexa4' is populated in column H.

    This needs to happen on every sheet. The original code works but i manually have to go to each sheet and run the code - i would like to update all sheets from a button on the home tab.

    I'm sorry if it's difficult to understand!

  13. #13
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,484

    Re: Cope data from another sheet based on cell criteria

    See post 9 ...And uploaded sample.....
    I deleted the code from all the sheet modules....
    Code goes in a std module and gets called once you click your thank you Form
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    I can't thank you enough! That works just how i need it to.
    Just one niggle... After I click the Thank you it now redirects to the PatientList sheet but i would rather it stays on on the Home sheet. What do I need to change for that?

    Thanks again
    Stuart

  15. #15
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    Al, it seems to duplicate when i add another patient to the list. Is there a way to prevent that?

  16. #16
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    I'm so sorry, i've also noticed another requirement i've not thought of. I know i'm being a pain!
    Is it possible to only copy and paste columns A:H? It's just further columns will be active in the study sheets where users can add further data.
    As it is, copying and pasting the entire row will delete any data added in columns I onwards.

  17. #17
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,484

    Re: Cope data from another sheet based on cell criteria

    Please Login or Register  to view this content.
    before
    Please Login or Register  to view this content.
    seems to duplicate
    Why don't you just update the client named sheet immediately....

    Edited:

    Your requests have changed since your initial thread...i suggest you start over and explain in detail what you need...so that no time is wasted on unnecessary or incorrect code.
    Last edited by Sintek; 06-20-2017 at 11:21 AM.

  18. #18
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,484

    Re: Cope data from another sheet based on cell criteria

    I suggest that you amend your add patient code to the following and delete the other code we were working on:
    This will add to patient list and automatically add to the specific patient tab
    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Cope data from another sheet based on cell criteria

    Thanks again sintek, this has worked.
    The only issue i'm now left with is that where someone adds includes a date in the userform it's not recognised as a date unless i 'text to columns' the row (row H in this case).

    Is it possible to add this onto the end of your code? Then it will do everything i need it to!

  20. #20
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,484

    Re: Cope data from another sheet based on cell criteria

    The only issue i'm now left with is that where someone adds includes a date in the userform it's not recognised as a date unless i 'text to columns' the row (row H in this case).
    Explain in more detail....I do not understand

+ 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: 0
    Last Post: 05-02-2016, 07:59 AM
  2. VBA code that finds data based on criteria, moves up two rows, copies cell to new sheet
    By Excelsior12 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2016, 05:47 PM
  3. [SOLVED] Transfer Cell Data From 1 Sheet To Another Based on Criteria
    By thecircularwriter in forum Excel General
    Replies: 10
    Last Post: 01-24-2016, 04:46 PM
  4. Replies: 2
    Last Post: 01-23-2016, 01:16 PM
  5. [SOLVED] Paste data to another sheet based on cell criteria(s) - VBA Excel 2010
    By magneto_sphere in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2015, 11:40 AM
  6. Replies: 4
    Last Post: 01-08-2013, 12:37 PM
  7. copy a row of data to new sheet based on a criteria using cell.offset
    By Naniboo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2010, 04:03 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