+ Reply to Thread
Results 1 to 12 of 12

VBA Macro to fill copied data uptill the last used row

  1. #1
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    VBA Macro to fill copied data uptill the last used row

    Hello,

    I want to copy B2 & B3 and paste it down till the last used row. Below is the pic

    allocation.PNG


    I tried it but i am getting an run time error 1004: The info cannot be pasted because the copy area and the paste area are not same size and shape.

    Below is the VBA code:
    Please Login or Register  to view this content.
    Can any one help me on this

    Thank You !

    Regards
    Wither
    Attached Files Attached Files
    Last edited by alansidman; 06-11-2016 at 03:23 PM. Reason: code tags added

  2. #2
    Registered User
    Join Date
    11-01-2012
    Location
    Cairo, Egypt
    MS-Off Ver
    MS Office 2013
    Posts
    76

    Re: VBA Macro to fill copied data uptill the last used row

    Try this:

    Please Login or Register  to view this content.
    Last edited by Subverter; 06-11-2016 at 01:39 PM.

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Macro to fill copied data uptill the last used row

    Or this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

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

    Re: VBA Macro to fill copied data uptill the last used row

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    @Wither125
    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    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

  5. #5
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA Macro to fill copied data uptill the last used row

    Hello Subverter,

    thanks for your reply the code works, but its pasting the names even to the un-selected data.

    In the below code first i am filtering the country column and selecting US ,CA and then i want to assign Brandon ,Alan to US CA only. Below in the pic u can see there are three county US CA BR.

    all.PNG

    So the problem is its copying Brandon and Alan even to the BR though i am filtering US and CA.

    Please Login or Register  to view this content.

    Regards
    Wither
    Attached Files Attached Files
    Last edited by Wither125; 06-12-2016 at 02:14 PM.

  6. #6
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA Macro to fill copied data uptill the last used row

    Hi xladept,

    Thanks for your reply! But i am still facing a problem that its filling the names even to the un-selected data.

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Macro to fill copied data uptill the last used row

    Well Wither, how could we have known about the filter? Can you post a more relevant sample?

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Macro to fill copied data uptill the last used row

    This depends upon the leading rows being filled:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA Macro to fill copied data uptill the last used row

    Hello xladept,

    i ran your code and its assigning Brandon to US and Alan to CA. But i want both of them to be assigned to US and CA as seen in the below pic.

    alres.PNG

    In the below code first i am filtering the country column and selecting US ,CA and then assigning Brandon and Alan to US,CA.

    Please Login or Register  to view this content.
    I tried your code but its its filling the names even to the un-selected data.

    Please Login or Register  to view this content.
    i want to copy B2 & B3 and paste it down till the last used row. So how do i do that?

    Regards
    Wither
    Attached Files Attached Files
    Last edited by Wither125; 06-14-2016 at 05:07 PM.

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Macro to fill copied data uptill the last used row

    How do you determine who goes where?

  11. #11
    Registered User
    Join Date
    05-16-2016
    Location
    bangalore,India
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA Macro to fill copied data uptill the last used row

    Well first filter the country and select US CA and then assign Brandon and Alan and then copy Brandon,Alan and paste it down till the last used row.

    alres.PNG

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Macro to fill copied data uptill the last used row

    Thanks for the rep!

+ 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 clears data from col A and B of the existing data when copied.
    By meseret in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-12-2015, 05:21 AM
  2. Macro to save copied data
    By namluke in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2014, 03:53 PM
  3. [SOLVED] When data is copied to another workbook, hyperlinks as not copied or they don't work
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-17-2014, 06:46 AM
  4. [SOLVED] Copied Cells Fill Black
    By robpopper in forum Excel General
    Replies: 2
    Last Post: 10-26-2013, 12:53 PM
  5. [SOLVED] Macro will not move copied data to next blank row?
    By DG370 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-15-2013, 10:54 AM
  6. [SOLVED] Apply Formula Uptill Last Row
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-10-2012, 10:21 AM
  7. wrong data copied into new cell from macro
    By johnmerlino in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2011, 10:42 AM

Tags for this Thread

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