+ Reply to Thread
Results 1 to 5 of 5

automate copying cells into new worksheet if notblank, same worksheet if blank

  1. #1
    Registered User
    Join Date
    12-20-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2003
    Posts
    7

    Red face automate copying cells into new worksheet if notblank, same worksheet if blank

    hi forum!!

    I have a spreadsheet with patient information that another company has asked for in a different format than they used to. instead of needing it as lines in a spreadsheet format they now want in separate sheets, divided by patient. Basically it's a form for each individual that they sent via a word doc that I copied into excel because I figured it'd be easier to transfer the data. Only problem is, I don't know the programming language at all. I've attached a spreadsheet example, where the names/demographic sheet is where I'm pulling the information from and the form sheet is where I want it transferred to. I need a script that does the following (and if anyone wants to just point me in the right direction on this, without doing all the heavy lifting, any level of assistance at all would be much appreciated!!) (note:my biggest struggle is how go to the next line when the script loops through, or specify whatever line it should be working on):

    row X, if column A is NOTBLANK copy entire "form" sheet (so i can preserve the template)
    then, in that newly copied sheet ("form (2)"), copy name, DOB, ID and first line of charges from "name_demographics" into correct fields on "form" sheet
    if BLANK, create a new charge line in "form" sheet by copying row and inserting copied cells (<-- each patient will have a different amount of charges, so i don't want to run out of space for that)
    copy charge code and amount from "name_demographics" sheet into "form (2)" sheet
    next row, restart

    I also don't know how to make it stop at the end (when there's no data in any of the lines... it'll be at a specified row though so i guess that helps).

    thank you so much!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: automate copying cells into new worksheet if notblank, same worksheet if blank

    This Macro will do what you ask.
    The ID No id the sheet name.

    I would however create an Index sheet to find the ID using the client name

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: automate copying cells into new worksheet if notblank, same worksheet if blank

    FWIW:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: automate copying cells into new worksheet if notblank, same worksheet if blank

    Ok

    This version populates an index sheet.

    Run Macro1 to import your data

    then enter Joe into cell A2 of the index sheet and press enter.

    Click on the line that you want
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-20-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: automate copying cells into new worksheet if notblank, same worksheet if blank

    Thanks to both of you for the responses! I tried working through both scripts and realized that a mock spreadsheet wasn't the way to showcase my issue, just because of the various approaches that one might take in certain situations versus others. I tried to edit them to fit the cells in my spreadsheet (which I can't share due to HIPAA laws), but it just didn't seem like it would work no matter what. It might seem haphazard, but the following are the places I need things copied:

    In rows where columns A-E have nonblank cells, the A cell (in the "names" sheet) needs to go to D6 (always this specific cell in the "form" sheet). B to D7, C to H6, I to F8, E to D11, F to B37, H to E37.

    In rows where columns A-E are blank on the "names" sheet, this means that we're still filling in data on the form for the above person. I need the datum in column F to go to whatever B cell on the "form" is open underneath B37... That is, if this is the first blank row, it would go in B38, if this is the second blank row for this person I would need it to go in B39, and so on. This is the same for the H datum, which I need to go to E38 and so on.

    The copying of the form and renaming of the sheets worked really well. I'm working in Office 2013. Thank you both so much for your assistance!

+ 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. Copying cells dynamically to a worksheet based on values in another worksheet
    By freelance in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2013, 01:45 PM
  2. [SOLVED] Copying selected cells from multiple rows and columns from worksheet to worksheet
    By janlindgren in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2012, 02:58 AM
  3. Copy certain cells from one worksheet to another worksheet with blank rows
    By pmarsella in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-06-2009, 07:57 AM
  4. [SOLVED] Copying a worksheet witrh protected cells to a new worksheet
    By John in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-01-2006, 10:25 AM
  5. How can I automate copying blank worksheet?
    By unsworthcl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2005, 12:52 PM

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