+ Reply to Thread
Results 1 to 10 of 10

Copy last 3 columns, paste into next blank column macro

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Copy last 3 columns, paste into next blank column macro

    Hi,

    I have a spreadsheet where I'd like to be able to find the last 3 active columns, copy them and paste them into the next blank column for the active sheet.

    So e.g., column Z is my last column with data, so I need to copy X, Y and Z, then paste them into AA, AB and AC.

    It will always be the same sheet (Sheet 1) which I'm copying and pasting from and into, so the sheet name can be specified (i.e. it doesn't have to be for whichever sheet is active at the time.

    Any help would be greatly appreciated.

    Cheers,

    Ross

  2. #2
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Copy last 3 columns, paste into next blank column macro

    Try this:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Copy last 3 columns, paste into next blank column macro

    Hi ARowbot,

    Thanks for swift reply. Won't work though I'm afraid.

    Get run-time error '1004': That command cannot be used on multiple selections.

  4. #4
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Copy last 3 columns, paste into next blank column macro

    Very strange! I have tried and tested this. Can you upload an anonymous workbook please as there is clearly some other factor that I have not thought of!

  5. #5
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Copy last 3 columns, paste into next blank column macro

    I get it to work in a test file too! Hmmmm, let me try and sus what's different, as works spot on when just created a quick sample one!!

  6. #6
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Copy last 3 columns, paste into next blank column macro

    I think the issue is that the sheet I'm trying to apply it to is filter by multiple filters. If I clear all filters it works fine, but if the filters are applied, it doesn't work.

    I can probably work around that though, as the filters are applied by macro, so I could unfilter, have this macro run, then refilter maybe. Just got to work out the right order for all the macros that auto run and over things the workbook does to see if I can work with that.

  7. #7
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Copy last 3 columns, paste into next blank column macro

    If the sheet already has a filter on then:
    Please Login or Register  to view this content.
    Will remove it.
    Then apply my macro
    Then you can either reapply your filtering macro or at the bottom of my macro put:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Copy last 3 columns, paste into next blank column macro

    Cheers,

    Already got the unfaltering sorted and working fine.

    Last thing I'd want to do is to auto-highlight the 3 columns that have been pasted (i.e. the 3 columns that are now the last 3 columns)

    How do you just select the last 3 active columns?

  9. #9
    Registered User
    Join Date
    07-10-2013
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Copy last 3 columns, paste into next blank column macro

    Actually, scrap that, got that bit sussed from adapting your original: -

    With Sheets("Sheet 1")
    Lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
    Columns(Lastcol - 2).Resize(, 3).Select
    End With

    Thanks for your help

  10. #10
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Copy last 3 columns, paste into next blank column macro

    You're welcome. If all the problems are now solved then please mark the thread as solved using thread tools at the top.

    And If I have helped then any reputation you may wish to give would also be appreciated

+ 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. Macro: Copy/Paste values From Column to Next Blank Row
    By Lisseth225 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2014, 05:39 PM
  2. [SOLVED] Need VBA Macro to Copy and paste column data in blank rows and repeat through spreadsheet
    By slk1186 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-07-2014, 12:50 PM
  3. Macro to copy and paste a single column into several different columns
    By Matt2014 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2014, 08:37 AM
  4. [SOLVED] Macro to copy columns and paste into one column in next blank column
    By rmmohan in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-31-2013, 03:14 PM
  5. Macro to copy values from columns of one sheet & paste it to diffrnt Column Sequence
    By kmvasudha in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2013, 06:54 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