Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Avi Avi is offline
external usenet poster
 
Posts: 29
Default Protect cell - VBA

Hi,

I want to protect cells of a particular color usning this code

Sub Protectme()
For i = FirstRow To RowCount 'row
For j = FirstCol To Colcount ' col
If CellColorIndex(Cells(i, j)) = 24 Then
Range.Cells(i,j).Locked = True --- Some problem in this line
End If
Next j
Next i
ActiveSheet.Protect
End Sub

This gives me a run time error.. Can somebody help me ??

Thanks,
Avinash

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Protect cell - VBA

Try

Cells(i,j).Locked = True

Regards

Trevor


"Avi" wrote in message
oups.com...
Hi,

I want to protect cells of a particular color usning this code

Sub Protectme()
For i = FirstRow To RowCount 'row
For j = FirstCol To Colcount ' col
If CellColorIndex(Cells(i, j)) = 24 Then
Range.Cells(i,j).Locked = True --- Some problem in this line
End If
Next j
Next i
ActiveSheet.Protect
End Sub

This gives me a run time error.. Can somebody help me ??

Thanks,
Avinash



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
Protect or Unprotect Cell dependent on different cell David Bruce Excel Discussion (Misc queries) 2 March 26th 10 02:19 PM
Is it possible to protect cell formatting in an unlocked cell? Robotbird Excel Discussion (Misc queries) 2 August 25th 09 01:38 PM
EXCEL: Protect a cell depending on another cell value frenchflo Excel Worksheet Functions 1 October 11th 06 05:36 PM
Protect Cell Steven Excel Worksheet Functions 1 January 21st 06 06:37 PM
protect specific cell but allow edit on other cell chiuinggum Excel Worksheet Functions 5 December 8th 05 06:22 PM


All times are GMT +1. The time now is 06:20 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"