Writing Data From One Workbook to Another Workbook via VBA

Hardware Man

New Member
Joined
Apr 10, 2013
Messages
40
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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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