Results 1 to 3 of 3

Need to paste with an offset targeting empty cell

Threaded View

  1. #1
    Registered User
    Join Date
    01-17-2018
    Location
    Buffalo, New York
    MS-Off Ver
    2016
    Posts
    24

    Need to paste with an offset targeting empty cell

    Hey Everyone,

    I'm new to VBA and have a problem that is driving me up a wall! Any help would be greatly appreciated!

    My eventual goal is to loop through all active workbooks and copy each region (minus a few rows at the top) and then paste these rows in succession in another workbook. All 10+ of these sheets should have their data stacked on top of each other in the new worksheet with one blank row in between. Here is the code I have used below...

    Public Sub CopoyPastaInvoices()

    'Copying the data in each open worksheet and offsetting the top three lines
    Dim rng As Range
    Dim Lastrow As Long

    Set rng = Workbooks("C3002171210_35267058.csv").Worksheets(1).Range("A1:A4").CurrentRegion
    Set rng = rng.Offset(3, 0)
    Set rng = rng.Resize(rng.Rows.Count - 3)
    rng.Copy ThisWorkbook.Worksheets("UNFI Invoice Drop In 2").Cells(Rows.Count, 1).End(xlDown).Offset(2, 0)

    End Sub

    The bold code is giving me an error of "Application-defined error". I think it is related to the fact that I have .end.offset after the .cells. Is it possible to paste with an offset directly after a copy? What I am missing here?

    Any help would be great appreciated!

    -tvxl
    Last edited by tvxl; 01-17-2018 at 12:36 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Paste Values empty cell, not empty
    By warston in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 12-23-2020, 08:16 PM
  2. COUNTIFS [Targeting a value that is the same as a cell name [A1, S55]
    By JohnoLFC in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-13-2016, 08:33 AM
  3. [SOLVED] Paste formula to the last empty cell based on a non-empty cell on another column
    By bhenlee in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2015, 04:07 PM
  4. looping to find empty cells and color the offset (0, 1) cell.
    By Neil35 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-07-2015, 02:53 PM
  5. [SOLVED] Targeting Worksheet Name by Cell Value
    By daffodil11 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2014, 05:04 PM
  6. Next empty cell then offset and run macro
    By cooper1308 in forum Excel General
    Replies: 3
    Last Post: 11-01-2009, 07:54 AM
  7. Using offset to select next empty cell
    By NewExcelUser in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-02-2007, 06:32 PM

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