+ Reply to Thread
Results 1 to 3 of 3

Copy and Paste in a Table

Hybrid View

  1. #1
    Registered User
    Join Date
    05-14-2008
    Location
    Hong Kong
    MS-Off Ver
    2019
    Posts
    59

    Copy and Paste in a Table

    Hi There,

    I got a Table with 2 column. 1st column Label as Desk, and 2nd column label as Asset. What I like to do is that, when I key in the data into the Desk cell and Asset cell, when it goto the second row, it will automatically copy the last value from desk column

    Example: Assuming this is the table:

    Desk | Asset
    ----------------------------
    Desk01 | Asset01 "Once I press Tab, it will goto the next row, Then it copy the last record which is "Desk01" down.
    Desk01 | Asset02


    Please advise how to do that in VBA.

    Thanks

  2. #2
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: Copy and Paste in a Table

    Behind the sheet module

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     With Range("A" & Rows.Count).End(xlUp)
      If Target.Address = .Address Then
        If .Offset(-1, 1) <> "" Then .Resize(, 2) = Array(.Offset(-1), "Asset" & Format(Val(Right(.Offset(-1, 1), 2)) + 1, "00"))
      End If
     End With
    End Sub
    Last edited by JEC.; 09-13-2024 at 11:21 AM.

  3. #3
    Registered User
    Join Date
    05-14-2008
    Location
    Hong Kong
    MS-Off Ver
    2019
    Posts
    59

    Re: Copy and Paste in a Table

    Hi Jec,

    This is good, but I might not explain it properly.

    1. in the Asset Column, when I entered the data and press tab, it will goto next row, then it will copy the data from above.
    2. I want to cursor to move to right automatically, so that I can enter the second asset info.

    See attached file.

    Many thanks
    Attached Files Attached Files

+ 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. Copy and Paste table into Email - Adding lines before table
    By siouxlini in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2024, 08:50 PM
  2. Replies: 1
    Last Post: 05-11-2021, 04:58 PM
  3. Copy cell values, add a new row on table and paste them at the bottom of a table
    By ApexDmac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2019, 11:00 AM
  4. Replies: 22
    Last Post: 01-30-2019, 01:09 PM
  5. [SOLVED] Copy and paste formula outside pivot table using information from table
    By batjl9 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-01-2014, 07:10 AM
  6. Macro to Copy Pivot Table and Paste a Regular Data Table in the Same Position
    By webfeet2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2013, 06:34 AM
  7. Macro to copy a table and paste in another table (based on certain conditions)
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-22-2013, 01:14 PM

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