Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    52

    Unanswered: Adding contents of two tables

    I wish to use VBA to add the data from one table (C3:AK18 in Sheet1) to the data of another table (C3:AK18 in Sheet2). Both tables just contain numbers and the tables are obviously the same size. How do you create a button so that when it is clicked the data from the first table is automatically added to the data in the second table? I am a beginner when it comes to VBA.

  2. #2
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    511
    Hi,

    Just to be clear, which of these results do you want?
    Table 1 (example)
    Code:
    1    1
    2    3
    Table 2 (example)
    Code:
    0    1
    2    3
    Result (A) - Table 2
    Code:
    1    2
    4    6
    Result (B) - Table 2
    Code:
    0    1
    2    3
    1    1
    2    3

  3. #3
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    52

    Adding contents of two tables

    I am hoping for the result you have called (A), thank you.

  4. #4
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    511
    Here's one way of many:
    Code:
    Sub Button1_Click()
     
        Sheet2.Range("TableB").Value = [Sheet1!TableA + Sheet2!TableB]
     
    End Sub
    Attached Files Attached Files

  5. #5
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    52

    Adding contents of two tables

    Thank you, Colin.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •