+ Reply to Thread
Results 1 to 8 of 8

Macro to copy and paste range based on cell value

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    24

    Macro to copy and paste range based on cell value

    Hi all,

    I have a spreadsheet which may contain "here" anywhere within the range L4:R24.

    I need a macro to look for the word "here", cut the cell together with the 9 cells below it and paste it in A1:A10.

    Eg. If cell M7 contains the word "here"
    then, the macro should cut the cells M7:M17 and paste it in cells A1:A10.

    Thank you.

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,709

    Re: Macro to copy and paste range based on cell value

    Perhaps like this?

    Please Login or Register  to view this content.
    Alf

  3. #3
    Registered User
    Join Date
    04-06-2012
    Location
    Erode, India
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Macro to copy and paste range based on cell value

    Hi PFA,



    Thanks,
    Vinodh.T,
    Erode City
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to copy and paste range based on cell value

    Could there be more than one cell with "here" within the range?

  5. #5
    Registered User
    Join Date
    08-21-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro to copy and paste range based on cell value

    No, but I would need to repeat this through different worksheets.
    I have tried
    Please Login or Register  to view this content.
    It is only running for the first page and then giving me an "400" error.

    Thanks.

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

    Re: Macro to copy and paste range based on cell value

    NOT

    Please Login or Register  to view this content.
    Should be

    Please Login or Register  to view this content.

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,709

    Re: Macro to copy and paste range based on cell value

    Try this
    Please Login or Register  to view this content.
    Alf

  8. #8
    Registered User
    Join Date
    08-21-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro to copy and paste range based on cell value

    Hi,

    I have both tried to change the
    Please Login or Register  to view this content.
    and add the
    Please Login or Register  to view this content.
    line but I am still getting the 400 error.

    It seems to be working fine for the first sheet only.

    Also, there should be only one "here" throughout the range.

    Thanks

  9. #9
    Registered User
    Join Date
    08-21-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro to copy and paste range based on cell value

    Figured it out. I needed to change these from
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Thanks for all your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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