ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   lock cells (https://www.excelbanter.com/excel-programming/327056-lock-cells.html)

[email protected]

lock cells
 
Hi,
I have an information in cells D1:J10.
This information will be updated and added . It means that number of
row can be change any time.
When program is running I use command:
Worksheets("sheet1").Columns.Clear
To save this info I tried to lock that column before Clear:
Worksheets("sheet1").Range("D1:J10").Locked = True , but it is
doesn't help.
How can I save info in that columns.
Thanks'


Rowan[_2_]

lock cells
 
The Locked property only applies when the worksheet is protected. If the
worksheet was protected then your Columns.Clear command would result in an
error.

You need to think about why you are running the line of code:
Worksheets("sheet1").Columns.Clear
which clears all data on the sheet. You obvioulsy don't want to do that so
you should determine what range of cells you do want to clear and direct the
macro to just that range. E.g if you only want to clear columns A to C then:
Worksheets("sheet1").Columns("A:C").Clear

Hope this helps
Rowan

" wrote:

Hi,
I have an information in cells D1:J10.
This information will be updated and added . It means that number of
row can be change any time.
When program is running I use command:
Worksheets("sheet1").Columns.Clear
To save this info I tried to lock that column before Clear:
Worksheets("sheet1").Range("D1:J10").Locked = True , but it is
doesn't help.
How can I save info in that columns.
Thanks'




All times are GMT +1. The time now is 01:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com