+ Reply to Thread
Results 1 to 7 of 7

Copy/Paste Adjacent Cells based on ActiveCell

  1. #1
    Registered User
    Join Date
    02-20-2013
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    28

    Copy/Paste Adjacent Cells based on ActiveCell

    Hello,

    I am looking for a piece of code that will search through the data in column E and if the value in column E is #N/A, then it will copy the adjacent data in columns A-D into a new worksheet.

    I have tried using Offset to select the 4 cells to the left of the activecell but I cannot select all 4 at the same time.

    Any help is greatly appreciated!

    Thank you!

    Sam
    Last edited by brgr4u; 04-24-2013 at 03:41 PM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copy/Paste Adjacent Cells based on ActiveCell

    Hi, Sam,

    maybe this may give you a hint:
    Please Login or Register  to view this content.
    Cioa,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    02-20-2013
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Copy/Paste Adjacent Cells based on ActiveCell

    I think that may get me close, can you tell me if what I came up with is workable?

    on the line that contains "If Activecell.Value = "N/A" Then" it kicks out a mismatch error

    Please Login or Register  to view this content.
    Last edited by brgr4u; 04-24-2013 at 02:48 PM.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copy/Paste Adjacent Cells based on ActiveCell

    Hi, brgr4u,

    what does not available mean for Excel? An error occurred - maybe thatīs why I used IsError.

    And there is hardly one good reason to select each and every cell to work with ActiveCell (except a lot of unnecessary cursor movement and the macro recorder displaying code like that with Selection).

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    02-20-2013
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Copy/Paste Adjacent Cells based on ActiveCell

    That makes a lot of sense, but is it possible to put a copy/paste function in the same For-Next Loop? I would like to copy the data in columns A-D adjacent to the activecell to the bottom of Column B in another sheet.

    The original sheet is called "Apr Pivot" and the sheet data will be pasted into is called "Lookup"

    Thank you for all your help already!!

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copy/Paste Adjacent Cells based on ActiveCell

    Hi, brgr4u,

    do you have any formulas that you want to copy? I generally try to put values into the backup sheet as the data may show different results from what they showed on the original sheet.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Last edited by HaHoBe; 04-24-2013 at 03:43 PM. Reason: typos - why do I care to look at the posting in preview? :(

  7. #7
    Registered User
    Join Date
    02-20-2013
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Copy/Paste Adjacent Cells based on ActiveCell

    Yes!!!!! Thank you!!!

+ 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