+ Reply to Thread
Results 1 to 6 of 6

Copy and paste data from one tab into another tab into first blank cell

Hybrid View

  1. #1
    Registered User
    Join Date
    10-12-2014
    Location
    Australia
    MS-Off Ver
    Office 2010
    Posts
    4

    Copy and paste data from one tab into another tab into first blank cell

    Hi,

    I have tried to solve this problem myself, but am struggling with some of the code that is online as I am very new to VBA.

    What I want to do is write data in one tab and then run a macro that copies the data and pastes it into another tab, it then wipes the original data that was input and is ready for more data to be loaded. The difficulty I am having is getting the code to find the next blank cell and then post the data there rather than overriding the data from running the first macro.

    Specifically my coding is as such.

    Sub Macro2()
        Sheets("INPUT").Select
        Range("B4:J15").Select
        Selection.Copy
        Sheets("USERDATA").Select
        Range("B9:J20").Select ******Instead of pasting into this range I want it to find the first blank space in column B9 and then paste********
        ActiveSheet.Paste
    
    
        Sheets("INPUT").Select
        Range("B4:J15").Select
        Selection.ClearContents
    
    End Sub
    Any help on how I would code that specific part would be appreciated.

    Thanks
    Dom
    Last edited by alansidman; 11-08-2014 at 09:54 PM.

  2. #2
    Registered User
    Join Date
    10-12-2014
    Location
    Australia
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Copy and paste data from one tab into another tab into first blank cell

    **Was just meaning column B, not B9.

  3. #3
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Copy and paste data from one tab into another tab into first blank cell

    Hi Dom,

    try this:
    Sub Macro3()
    
        Dim rngIn As Range, rngOut As Range
    
        Set rngIn = Sheets("INPUT").Range("B4:J15")
        Set rngOut = Sheets("USERDATA").Columns("B")
        Set rngOut = rngOut.Find(Empty, rngOut.Cells(rngOut.Cells.Count), xlValues, xlWhole)
    
        If Not rngOut Is Nothing Then
            rngIn.Copy rngOut
            rngIn.ClearContents
        End If
        
    End Sub
    Regards,
    berlan

  4. #4
    Registered User
    Join Date
    10-12-2014
    Location
    Australia
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Copy and paste data from one tab into another tab into first blank cell

    Worked a charm. Thanks heaps spent ages trying to work it out myself.

    Dom

  5. #5
    Registered User
    Join Date
    10-12-2014
    Location
    Australia
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Copy and paste data from one tab into another tab into first blank cell

    I am using the below formula and need it to paste as paste values. Currently it is a normal paste.

    Do you know how I can edit this so it pastes as PV.

    Thanks
    Dom


    Dim rngIn As Range, rngOut As Range
    
        Set rngIn = Sheets("INPUTSIMPLE").Range("F9:J24")
        Set rngOut = Sheets("DB").Columns("A")
        Set rngOut = rngOut.Find(Empty, rngOut.Cells(rngOut.Cells.Count), xlValues, xlWhole)
    
        If Not rngOut Is Nothing Then
            rngIn.Copy rngOut
            rngIn.ClearContents
    Last edited by alansidman; 11-08-2014 at 09:54 PM.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,719

    Re: Copy and paste data from one tab into another tab into first blank cell

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

    Posting code between [CODE] [/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

+ 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. [SOLVED] Formula to Copy/Paste data based on value of another cell. SKIP BLANK ROWS.
    By mamero in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-14-2015, 04:46 PM
  2. Copy and paste in first blank cell
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-05-2013, 01:42 AM
  3. Copy and paste if cell value is not blank
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2012, 07:09 AM
  4. Excel 2007 : Copy data ok but paste blank!
    By gozo in forum Excel General
    Replies: 1
    Last Post: 07-24-2009, 08:35 PM
  5. vba for copy paste to blank cell
    By Lazypanda in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-20-2008, 09:38 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