This example may look a little be confusing to a new user but it is actually quite simple. Workbooks( 'MyVBA.xlsm').Worksheets( 'Sheet1').Range( 'A1') = 100 End Sub
' Public Sub WriteToA1() ' Writes 100 to cell A1 of worksheet 'Sheet1' in MyVBA.xlsm You will notice we had to specify the workbook, worksheet and range of cells. The following example shows you how to write to a cell on a worksheet. xlsm “ ). Simply replace Example.xlsm with the name of the workbook you wish to use. We can access any open workbook using the code Workbooks( “Example. ( Note: Website members have access to the full webinar archive.) If you are a member of the website, click on the image below to access the webinar. See File Dialog section below function below Set wk = Workbooks.Open ( 'C:\Docs\Example.xlsx', ReadOnly:=True) Set wk =Workbooks.Open ( 'C:\Docs\Example.xlsx') The following table provides a quick how-to guide on the main VBA workbook tasksĪccess open workbook (the one opened first)Īccess open workbook (the one opened last) 14 Examples of the Accessing the Workbook.