Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Cells object question

I am using the Cells object to set the "locked" property of
my spreadsheet. The line looks like this:

Cells.locked = True ' or can be False

I feel real uncomfortable using that code by itself. Shouldn't
I pre-qualify the Cells object with another object such as
"ThisWorkbook" or something?? I just want to ensure that
this code runs on the workbook it was intended for and not
another active workbook.

Thank you!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Cells object question

Unless you know for certain that the sheet you are concerned with is the
activesheet then yes, you should always qualify the range object with the
relevant sheet, eg

ThisWorkbook.Worksheets("Sheet1").Cells.etc

In passing, I can't imagine why one would ever do .Cells.locked = False

Regards,
Peter T


"Robert Crandal" wrote in message
...
I am using the Cells object to set the "locked" property of
my spreadsheet. The line looks like this:

Cells.locked = True ' or can be False

I feel real uncomfortable using that code by itself. Shouldn't
I pre-qualify the Cells object with another object such as
"ThisWorkbook" or something?? I just want to ensure that
this code runs on the workbook it was intended for and not
another active workbook.

Thank you!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Cells object question

I always try to qualify my ranges.

With activesheet
.cells.locked = ...

Actually, I'd use:

Dim wks as worksheet
set wks = activesheet

with wks
.cells.locked = ...

By using that wks variable (declared as a worksheet), I'll get all the helpful
intellisense from the VBE. I think it makes writing code much easier.

Robert Crandal wrote:

I am using the Cells object to set the "locked" property of
my spreadsheet. The line looks like this:

Cells.locked = True ' or can be False

I feel real uncomfortable using that code by itself. Shouldn't
I pre-qualify the Cells object with another object such as
"ThisWorkbook" or something?? I just want to ensure that
this code runs on the workbook it was intended for and not
another active workbook.

Thank you!


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Cells object question

Maybe because not all sheets need to have protection??? For example, nobody
uses my personal PC, and I don't care whether or not some of my sheets
or protected or not.....therefore, all the cells may be unlocked with a
call to ".Cells.locked = False"??? But ya, I understand that most people
would
rather have their spreadsheet entirely locked.


"Peter T" <peter_t@discussions wrote in message
...

In passing, I can't imagine why one would ever do .Cells.locked = False


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activate Object question Eva Excel Worksheet Functions 0 December 14th 07 12:41 AM
Activate Object question Eva Excel Worksheet Functions 0 December 14th 07 12:41 AM
Range Object Question abillmeier Excel Programming 2 December 30th 05 03:02 PM
Automation object question scottrm Excel Programming 1 November 2nd 05 06:34 AM
Object Variable question ibeetb Excel Programming 2 July 27th 04 04:24 PM


All times are GMT +1. The time now is 04:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"