I am getting an error in this line of code 'ax.nt.Range("A1").Value =…
- User
I am getting an error in this line of code 'ax.nt.Range("A1").Value = sp.nts.Range("A1").Value', Workbook Auxillary opens. The entire code is: Public Sub OpenNotesWindow()
Dim NoteWindow As Workbook Set NoteWindow = Workbooks.Open("G:\Shared drives\Swan School Site Premises\PREMISES MANAGEMENT\SERVICE PROVIDERS\Auxillary.xlsm")
With NoteWindow.Windows(1) .DisplayWorkbookTabs = False .WindowState = xlNormal .Height = 500 .Width = 800 End With
Dim sp As Workbook Dim nts As Worksheet Set sp = Workbooks("Service Providers.xlsm") Set nts = sp.Worksheets("Notes")
Dim ax As Workbook Dim nt As Worksheet Set ax = Workbooks("Auxillary.xlsm") Set nt = ax.Worksheets("Note")
ax.nt.Range("A1").Value = sp.nts.Range("A1").Value
NoteWindow.Windows(1).Visible = True End Sub
- Assistant
The error is likely due to a typo in the line of code. Instead of "ax.nt", it should be "nt" since "nt" is the variable assigned to the "Note" worksheet in the "Auxillary" workbook.
The corrected code for that line would be: nt.Range("A1").Value = sp.Worksheets("Notes").Range("A1").Value