+ Reply to Thread
Results 1 to 11 of 11

Macro to take text from multiple columns and eliminate blanks

  1. #1
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Macro to take text from multiple columns and eliminate blanks

    I use a =CONCATENATE formula in columns R,Z,AH,AP,AX,BF & BN to combine 2 cells in adjacent columns.

    I'm looking to run a macro that will take the data from the columns above and put them to a separate sheet and remove the rows that are blank.

    I attached a simple example of what I describe above.
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,871

    Re: Macro to take text from multiple columns and eliminate blanks

    Which column in your real life workbook will indicate the last row to be copied. In your current example, we have no way of knowing. That will change the line of code for lr. You will have to change the range column.

    Please Login or Register  to view this content.
    Last edited by alansidman; 04-04-2018 at 03:06 PM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to take text from multiple columns and eliminate blanks

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: Macro to take text from multiple columns and eliminate blanks

    Hi Alpha Frog, that works but what I can't have it do is combines text that's in the same row. For instance in Row4 there is text in column R & AH. When the code runs it combines those 2 cells into 1.

    alansidman, it would stop at row 698.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,871

    Re: Macro to take text from multiple columns and eliminate blanks

    I have changed the last row in the code above to 698. Is this a fixed number. Will it change?

  6. #6
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: Macro to take text from multiple columns and eliminate blanks

    No the row # will not change.

    When I run that macro the first column (R) fills in correctly. However all the other columns are not. see image below

    Capture.PNG

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,871

    Re: Macro to take text from multiple columns and eliminate blanks

    Ok. In cell N6 on Sheet 2, Place this term "Control"

    Here is amended code:
    Please Login or Register  to view this content.
    v N O P Q R S T U
    6 Control COLUMN R DATA COLUMN Z DATA COLUMN AH DATA COLUMN AP DATA COLUMN AX DATA COLUMN BF DATA COLUMN BN DATA
    7 1 ABAS ABAS
    8 2 ABAS
    9 3 ABAS SDAS
    10 4 4-AS
    11 5 ABAS
    12 6 ABAS ABAS
    13 7 ABAS
    14 8 ABAS
    15 9 TRAS
    16 10 36+AS
    17 11 SFAS
    18 12 GFAS
    19 13 SDAS
    20 14 ABAS
    21 15 ABAS
    22 16 ABAS

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to take text from multiple columns and eliminate blanks

    Quote Originally Posted by adamheon View Post
    Hi Alpha Frog, that works but what I can't have it do is combines text that's in the same row. For instance in Row4 there is text in column R & AH. When the code runs it combines those 2 cells into 1.

    I thought that's what you wanted.

    PERFERABLY ALL TEXT IN THE 8 COLUMNS ON SHEET1 WOULD BE COMBINED INTO 1 COLUMN HERE
    Can you better explain and give some examples?

  9. #9
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: Macro to take text from multiple columns and eliminate blanks

    AlphaFrog, sorry for the confusion. I'll try to explain better.

    Each cell that has text within the 8 columns on Sheet1 would be moved to 1 single column on Sheet2 with no spaces. I reattached the example with the Sheet2 data manually filled in as i think it should come in.

    From this:

    2.PNG

    To this:

    1.PNG
    Attached Files Attached Files
    Last edited by adamheon; 04-04-2018 at 04:26 PM.

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to take text from multiple columns and eliminate blanks

    Quote Originally Posted by adamheon View Post
    AlphaFrog, sorry for the confusion. I'll try to explain better.

    Each cell that has text within the 8 columns on Sheet1 would be moved to 1 single column on Sheet2 with no spaces. I reattached the example with the Sheet2 data manually filled in as i think it should come in.
    No problem. Try this...

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: Macro to take text from multiple columns and eliminate blanks

    worked perfect! thank you both!

+ 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. [SOLVED] Filter Data to Top Row of Column - Eliminate Blanks
    By sl729 in forum Excel General
    Replies: 2
    Last Post: 06-30-2016, 02:57 PM
  2. [SOLVED] Using COUNTA to Eliminate Blanks in a Drop Down List?
    By qanjorin in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-17-2016, 07:28 PM
  3. Eliminate Blanks from Pivot Table
    By Keibri in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-18-2015, 11:55 AM
  4. [SOLVED] If Formula for several columns with text and blanks - Help
    By sboteler in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-06-2014, 10:55 PM
  5. Macro Needed to Reorganize Data and Eliminate Blanks
    By bplantz3 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-15-2013, 12:45 PM
  6. Eliminate Text-To-Columns Prompt
    By Blewyn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-12-2007, 11:40 PM
  7. Eliminate blanks before a charachter chain
    By MónicaM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2006, 10:30 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