+ Reply to Thread
Results 1 to 8 of 8

VBA to Copy Columns Using Headers but Ignore Columns without Data

  1. #1
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    VBA to Copy Columns Using Headers but Ignore Columns without Data

    Hi!

    I use the following code to move data from one worksheet to another using column headers (see attached workbook). My issue is that if there isn't data in the column it copies the header into the second row.

    Is it possible to ignore columns without data?


    Please Login or Register  to view this content.

    Thanks!!
    Kate
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: VBA to Copy Columns Using Headers but Ignore Columns without Data

    Have not checked anything but noticed the period missing in front of Rows.
    Does that make a difference?
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: VBA to Copy Columns Using Headers but Ignore Columns without Data

    Thanks for your help, Jolivanes! But the period doesn't change anything.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to Copy Columns Using Headers but Ignore Columns without Data

    Hello phelbin,

    If I look at your issue from a different angle, is it not true that you actually only want to hide "Empty" Columns in "TimeSheet1"?

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  5. #5
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: VBA to Copy Columns Using Headers but Ignore Columns without Data

    No, I don't want to hide the empty columns on the Timesheet1 tab. This file goes to payroll and they want to keep it all visible.

    I could do a second bit of code that would delete non-numbers in that range. But I'd rather alter the code to account for it.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to Copy Columns Using Headers but Ignore Columns without Data

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: VBA to Copy Columns Using Headers but Ignore Columns without Data

    AB33, that worked perfectly!! You are awesome!

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to Copy Columns Using Headers but Ignore Columns without Data

    Hello phelbin,

    Try it this way,

    Please Login or Register  to view this content.
    @ AB33,

    Great stuff my friend!

    Regards.

+ 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. Copy columns to a new workbook if the headers row matched
    By haitran in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-13-2017, 06:32 PM
  2. [SOLVED] Copy columns of different headers
    By SBBmaster09 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-30-2016, 04:10 PM
  3. Copy columns to other worksheet with same headers
    By etaver87 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2016, 11:25 AM
  4. macro to add columns after existing columns and copy/paste headers and formulas
    By rhybeka in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2013, 02:35 PM
  5. [SOLVED] Copy pasting columns based on headers
    By krash297 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2013, 02:13 PM
  6. Copy data under specific columns in sheet1 n paste to sheet2 under the same headers
    By ShyamEXcel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2012, 02:15 PM
  7. Excel 2007 : Macro to copy columns based headers
    By rls1316 in forum Excel General
    Replies: 2
    Last Post: 04-25-2011, 10:22 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