+ Reply to Thread
Results 1 to 7 of 7

Copy/Paste Adjacent Cells based on ActiveCell

Hybrid View

brgr4u Copy/Paste Adjacent Cells... 04-24-2013, 02:12 PM
HaHoBe Re: Copy/Paste Adjacent Cells... 04-24-2013, 02:40 PM
brgr4u Re: Copy/Paste Adjacent Cells... 04-24-2013, 02:46 PM
HaHoBe Re: Copy/Paste Adjacent Cells... 04-24-2013, 03:00 PM
brgr4u Re: Copy/Paste Adjacent Cells... 04-24-2013, 03:10 PM
HaHoBe Re: Copy/Paste Adjacent Cells... 04-24-2013, 03:20 PM
brgr4u Re: Copy/Paste Adjacent Cells... 04-24-2013, 03:41 PM
  1. #1
    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!!

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

    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.

    Sub EF917764_2()
    Dim lngLast As Long
    Dim lngCounter As Long
    Dim wsData As Worksheet
    Dim wsCopy As Worksheet
    
    Set wsData = Sheets("Apr Pivot")
    Set wsCopy = Sheets("Lookup")
    
    With wsData
      lngLast = .Cells(Rows.Count, "E").End(xlUp).Row
    End With
    
    For lngCounter = 1 To lngLast
      If IsError(wsData.Cells(lngCounter, "E")) Then
        With wsCopy
          .Cells(Rows.Count, "B").End(xlUp).Offset(1, 0).Resize(1, 4).Value = wsData.Cells(lngCounter, "A").Resize(1, 4).Value
        End With
      End If
    Next lngCounter
    
    Set wsCopy = Nothing
    Set wsData = Nothing
    End Sub
    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? :(
    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

+ 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