Q:

VBA change value in another workbook

I need some help changing variables in another workbook.
First I open the workbook with Workbooks.Open ("test.xlsx")
When I try to change a cell value with Workbooks("test.xlsx").Worksheets("Sheet").Cells(1, 1).Value = VariableX it gives me error 9: subscript out of range. I don't see why it won't work. Can anyone help me out on this?

A:

Workbooks.open Returns a Workbook-object. Use this to reference the Workbook you want to manipulate:
dim wb as Workbook
set wb = Workbooks.Open("test.xlsx")
wb.Worksheets("Sheet").Cells(1,1).Value = variableX

' Close the workbook afterwards and save the changes
wb.Close True

