+ Reply to Thread
Results 1 to 5 of 5

Help with copying to last column

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Help with copying to last column

    I have a data set that does not always have info in column M, and when data copies, it stops at Column L when this happens... and i need it to go to the last column.

    The issue i know is in line
    Please Login or Register  to view this content.
    I have the last column defined earlier as "lcol = Cells(2, Columns.Count).End(xlToLeft).Column"

    How do I sub in that lcol variable into the rg equation without messing everything up???
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Help with copying to last column

    Hi, what if you would do the following:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

  3. #3
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Help with copying to last column

    Quote Originally Posted by Eastw00d View Post
    Hi, what if you would do the following:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    Hi Erwin.... That is almost perfect.

    When that runs, it is capturing what is in column A, and that needs to to happen. It is also not bringing over the header row for the data set.

  4. #4
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Help with copying to last column

    Yes, you can leave than the offset(1) part out, but with this you can find the limits of your range, like
    Please Login or Register  to view this content.
    so you can set these variables to your own needs and set for example a new range:
    Please Login or Register  to view this content.
    Cheers
    Erwin

  5. #5
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Help with copying to last column

    Sorry for not replying sooner! Just updated the code, and with a slight tweak to what you posted, it worked perfectly!

    Just removed the +1 from FirstRow and put it on the Lastrow
    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. [SOLVED] Copying cell data in one column when duplicate cells located in separate column
    By Excelcious in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-10-2015, 02:41 AM
  2. Replies: 2
    Last Post: 04-11-2014, 12:18 PM
  3. Prevent copying and pasting a cell from a column with data validation to another column
    By kieranoduill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2013, 10:02 AM
  4. [SOLVED] copying specific certain column data based on cell/column value to another sheet
    By arctic7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2012, 03:38 PM
  5. Matching column values in 2 sheets and copying another column over if match
    By cuberis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2012, 06:55 PM
  6. [SOLVED] Split One Column at Delimiter While Copying Contents of Second Column to Populate New Rows
    By medailSacrosanct in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-01-2012, 11:37 AM
  7. Copying a formula in a blank column as far as data in previous column
    By basildon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2005, 11:35 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