Writing Data From One Workbook to Another Workbook via VBA

Hardware Man

New Member
Joined
Apr 10, 2013
Messages
41
As the title of this post suggests, I'm trying to use VBA to write some data into another workbook. I did some looking on the internet and this is what I've found. This code doesn't crash, but it sure as heck isn't writing the data to anyplace where I'm expecting it!

Not sure what bearing this has on the case, but the 2 workbooks in question are in different folders. Also, the folders they are in are not just on my harddrive, but are uploaded to the cloud onto my OneDrive. Does this have a bearing on naming the file path? Thanks in advance!

Code:
Sub MYTest()

Dim mastWorkBook As Workbook

Set mastWorkBook = Workbooks.Open("1 New Master Amazon Report.xlsm")

mastWorkBook.Sheets(24).Cells(2, 4) = "test string"

End Sub
 
Last edited by a moderator:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
If you aren't getting an error, then the value is being written to D2 on the 24th sheet from the left in the workbook you opened.
 
Upvote 0

Forum statistics

Threads
1,225,741
Messages
6,186,761
Members
453,370
Latest member
juliewar

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