+ Reply to Thread
Results 1 to 6 of 6

Need to Combine Lines in Macro

  1. #1
    Registered User
    Join Date
    03-11-2015
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    7

    Need to Combine Lines in Macro

    Does anyone know how to combine cells containing text to the end of previously defined cells (in this case cells starting with a #) by using an Excel function or macro? I am trying to clean up med lists hundreds of drugs. Directions are scattered across multiple lines. Essentially a nice clean list with one cell per medication with instructions. Any insight on creating a macro for this would be greatly appreciated.

    1) ASPIRIN TAB,CHEWABLE 81MG TAKE ONE TABLET
    BY MOUTH DAILY FOR HEART
    PROTECTION
    2) ATORVASTATIN TAB 40MG TAKE ONE TABLET
    BY MOUTH DAILY TO LOWER CHOLESTEROL
    3) BUDESONIDE/FORMOTEROL INHL,ORAL INHALE TWO PUFFS
    BY MOUTH TWICE DAILY. ENSURE TO RINSE
    MOUTH AFTER EACH USE. FOR COPD
    4) CHLORTHALIDONE TAB 12.5MG
    TAKE ONE TABLET BY MOUTH DAILY FOR HYPERTENSION
    5) CIPROFLOXACIN TAB 500MG TAKE ONE TABLET BY MOUTH
    EVERY DAY FOR INFECTION
    6) FERROUS SULFATE TAB 325MG BY MOUTH TAKE ONE
    TABLET BY MOUTH
    EVERY DAY ON AN EMPTY STOMACH
    7) FLUNISOLIDE INHL,NASAL INSTILL 2 SPRAYS IN
    EACH NOSTRIL TWICE DAILY
    8) GABAPENTIN CAP,ORAL 600MG TAKE ONE CAPSULE BY MOUTH
    EVERY 12 HOURS FOR NERVE PAIN
    9) HALOPERIDOL INJ,SOLN 5MG/1ML INJECT 1ML
    IM EVERY 8 HOURS AS NEEDED FOR AGITATION
    10) HEPARIN INJ,SOLN 5000 UNIT/ML INJECT 1ML (5000 UNITS)
    SQ BID (Q12H)
    11) HYDRALAZINE INJ,SOLN 10MG/0.5ML IVP Q4HRS PRN
    SBP>180
    12) MIRTAZAPINE TAB 15MG TAKE ONE TABLET
    BY MOUTH EVERY NIGHT AT BEDTIME FOR DEPRESSION
    13) MORPHINE TAB,IR 15MG TAKE ONE TABLET BY MOUTH EVERY
    SIX HOURS AS NEEDED FOR BREAKTHROUGH PAIN
    14) MORPHINE TAB,SA 30MG TAKE ONE TABLET
    BY MOUTH TWICE DAILY FOR PAIN
    Attached Files Attached Files
    Last edited by adamrx83; 03-11-2015 at 08:59 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Need to Combine Lines in Macro

    This macro reads what is in the first column and writes the merged lines to the second column. Here is it implemented in your file.

    It assumes that the first line always starts a numbered item. It reads the lines in column A and outputs the merged lines in column B. It works for up to 999 numbered items.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-11-2015
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    7

    Re: Need to Combine Lines in Macro

    Thank you!!

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Need to Combine Lines in Macro

    Same result but different method,
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-11-2015
    Location
    Chicago
    MS-Off Ver
    2010
    Posts
    7

    Re: Need to Combine Lines in Macro

    How can I change the input and output columns in this code?

    Option Explicit

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 03-12-2015 at 09:19 PM.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Need to Combine Lines in Macro

    Change "a" for input column.
    Please Login or Register  to view this content.
    change 4 for output column.
    Please Login or Register  to view this content.

+ 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. Combine lines and then delete
    By mikey3580 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2015, 10:53 AM
  2. Combine and Sum full lines?
    By blkdymnd in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-01-2014, 09:14 PM
  3. combine lines
    By mchipser in forum Excel General
    Replies: 3
    Last Post: 10-10-2008, 03:13 AM
  4. Combine Two vba Lines(If Condition + Vlookup)
    By helmekki in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2005, 11:12 AM
  5. [SOLVED] How to combine lines of code?
    By Papa Jonah in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2005, 10:06 AM

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