+ Reply to Thread
Results 1 to 5 of 5

copying data using an array with criteria

  1. #1
    Registered User
    Join Date
    04-16-2007
    Posts
    5

    Exclamation copying data using an array with criteria

    I have a sheet, for sake of example lets say it looks like this:

    Name Patient# Hair Color Eye Color
    John 1 Brown Blue
    Mary 3 Blonde Green

    Lets call the sheet "TodaysPatients".

    I have sorted "TodaysPatients" according to patient#.

    I have another sheet calls "Patients" with all patient #s from 1 - 50 listed in column A.

    Problem: I want to take all the rows from "TodaysPatients" and copy them to "Patients" lining up their Patient Numbers. To make the the problem more complicated, I ONLY want to copy columns 1 and 3 and put them in colukmn 2 and 3 on the "Patients" sheet.

    Iw ould like ot do this in an array to avoid multiple changes from VBA to excel and many sheet changes.


    I need to do this all in VBA. PLEASE PLEASE PLEASE help!!

    Thanks in Advance!
    Last edited by Shylie; 04-16-2007 at 05:44 PM.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    No need to use arrays

    Try this macro

    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    04-16-2007
    Posts
    5
    I am getting an "Invalid use of object" on this line:
    Please Login or Register  to view this content.
    So I tried
    Please Login or Register  to view this content.
    and am now getting a subscript out of range on:
    Please Login or Register  to view this content.
    Last edited by Shylie; 04-16-2007 at 10:32 PM.

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    The macro is treating the word Sample as a variable.
    If Sample is a test word you are using then it needs to be inclosed in "

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-16-2007
    Posts
    5
    I forgot to mention one important detail.. I need it based on multiple criteria.. so like find patient # 1 and only paste those columns if say hair color is blonde and eye color is green

    I really appreciate the help

+ 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