Reputation: 89
I get "Object doesn't support this property or method" when using this code
Windows(formatBook).Worksheets(2).Range("B4").Value = title
I just want to put a value on Range B4 of the second sheet of the book in which the sheet name changes
I tried breaking down the code to
Windows(formatBook).Activate
Worksheets(2).Activate
Range("B4").Activate
ActiveCell.Value = title
and it works. Why did it give me the error on the first code and how do I shorten my code?
Upvotes: 2
Views: 462
Reputation:
While the Windows collection and Workbooks collection share many properties and methods, they are not completely interchangeable. In this case you need Workbooks.
Workbooks(formatBook).Worksheets(2).Range("B4").Value = title
Upvotes: 1