+ Reply to Thread
Results 1 to 2 of 2

VBA Copy column data from one table and paste into another table

Hybrid View

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    VBA Copy column data from one table and paste into another table

    In my workbook, I have two tables (with different row numbers/column numbers) in a "database" sheet. Table1 has data input manually, which I want to paste via macro into Table2 in the same columns; ie. the data in Table1, Column "City" must be copied and pasted into Table2, Column "City". Table2 is empty and should not have to be cleared first (I think) because I will only need to run the macro once.

    Can anyone point me in the right direction with this problem? I have been searching for some sample code and generally found the following:
    Worksheets(“Sheet1″).Range(“A1:D4″).Copy _
    Destination:=Worksheets(“Sheet2″).Range(“E5″)
    However how can I modify this for tables instead of ranges, as well as defined columns within those tables?

    Thanks in advance

  2. #2
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: VBA Copy column data from one table and paste into another table

    After recording a macro of copying/pasting column data between the tables I get the following code:
    Sub Macro4()
    
        Range("Table1[[Asset]:[Data]]").Select
        Selection.Copy
        Range("Table2[[Asset]:[Data]]").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    End Sub
    Is there a better/faster method that does not involve Select?

+ 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