Working with two workbooks

cristiander

New Member
Joined
Jul 4, 2017
Messages
7
I'm working on a workbook that needs to make modifications on other workbooks, but I can't get the most rudimentary functions to work.
I think I might be defining my workbooks incorrectly.

As a start I have made:
Code:
Sub Work_tables()
    
    Dim tbl_a As Workbook
    Dim tbl_b As Workbook
    
    Set tbl_a = Workbooks.Open("C:\Users\...\table_a.xlsm")
    Set tbl_b = Workbooks.Open("C:\Users\...\table_b.xlsm")

    tbl_a.Sheets("sheet1").Range("A1").Value = 1
    tbl_b.Sheets("sheet1").Range("A1").Value = 2
    
    
End Sub


But it's simply not working. It's not changing any values. I don't understand where the problem is.
Is there something wrong with the definitions?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Update:

I was using the macro in table_a, so instead of Set tbl_a = Workbooks.Open("C:\Users\...\table_a.xlsm") I needed to use Set tbl_a = ThisWorkbook
 
Upvote 0

Forum statistics

Threads
1,215,633
Messages
6,125,929
Members
449,274
Latest member
mrcsbenson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top