Thisworkbook property

rhombus4

Well-known Member
Joined
May 26, 2010
Messages
586
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
In the below lines the first 6 and the 11th work, but lines 7, 8, 9 and 10 don't work

Do you have to use Sheets when using ThisWorkbook

[myrange] = "Yes"
[myrange].Offset(0, 1) = "Yes"
Sheets("Sheet1").[myrange].Offset(0, 2) = "Yes"

Range("myrange").Offset(1, 1) = "Yes"
Sheets("Sheet1").Range("myrange").Offset(1, 2) = "Yes"
ThisWorkbook.Sheets("Sheet1").Range("myrange").Offset(1, 3) = "Yes"

ThisWorkbook.Range("A5").Offset(0, 1) = "Yes" 'Compile Error : Method or data member not found
ThisWorkbook.Range("myrange").Offset(4, 1) = "Yes" 'Compile Error : Method or data member not found
ThisWorkbook Range("myrange").Offset(4, 1) = "Yes" 'Compile Error : Invalid use of property
ThisWorkbook.[myrange].Offset(4, 1) = "Yes" 'Compile Error : Method or data member not found

ThisWorkbook.Sheets("Sheet1").[myrange].Offset(4, 1) = "Yes"
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If i told you to go to cell A1 of a workbook with 10 sheets which one would you go to? You would have a choice of ten cell A1s. All worksheets in a workbook have a cell A1. For that reason the parent of the cell is the worksheet not the workbook.
 
Upvote 0
Thanks

Knew you had to use sheet when using A1 for example but didn't realise you had to do it for named ranges as well seeing as [my range] isn't on every sheet it's only on one sheet, in my case sheet1.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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