Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Color locked cells only in specified range

In spite of someones efforts to help me, I am not able to modify or ?? the
following to work on locked cells (only) in the selected range in column C.
It is critical to the application. Will someone please help?

Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow
With ws.Range("C6:C" & ILastRow)
.Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B6=""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
End With
ws.Range("C6").Select

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Color locked cells only in specified range

I assume the worksheet is unprotected when you run the code


Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long, cell as Range

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow


For each cell in ws.Range("C6:C" & ILastRow)
With cell
.Select
if .Locked then
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B" & _
cell.row & =""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
end if
End With
Next
ws.Range("C6").Select

--
Regards,
Tom Ogilvy

"BEEJAY" wrote:

In spite of someones efforts to help me, I am not able to modify or ?? the
following to work on locked cells (only) in the selected range in column C.
It is critical to the application. Will someone please help?

Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow
With ws.Range("C6:C" & ILastRow)
.Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B6=""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
End With
ws.Range("C6").Select

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Color locked cells only in specified range

Tom:
Thanks so much for the impressively prompt response.
I'm getting a an error: Compile Error: Syntax error on the following:

..FormatConditions.Add Type:=xlExpression, Formula1:="=($B" & _
cell.row & = ""*"")"
As I was inputting the code, it kept on going back to the last = sign, and
indicating
Compile Error, Expected Expression.

Help Pls. (again)

"Tom Ogilvy" wrote:

I assume the worksheet is unprotected when you run the code


Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long, cell as Range

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow


For each cell in ws.Range("C6:C" & ILastRow)
With cell
.Select
if .Locked then
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B" & _
cell.row & =""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
end if
End With
Next
ws.Range("C6").Select

--
Regards,
Tom Ogilvy

"BEEJAY" wrote:

In spite of someones efforts to help me, I am not able to modify or ?? the
following to work on locked cells (only) in the selected range in column C.
It is critical to the application. Will someone please help?

Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow
With ws.Range("C6:C" & ILastRow)
.Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B6=""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
End With
ws.Range("C6").Select

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Color locked cells only in specified range

Looks like I had a typo. should have been cell.row & "= ""*"")"

I ran this successfully

Sub AARR()

Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long, cell As Range

ILastRow = ws.Range("B:B") _
.SpecialCells(xlCellTypeLastCell).Row


For Each cell In ws.Range("C6:C" & ILastRow)
With cell
.Select
If .Locked Then
.FormatConditions.Delete
.FormatConditions.Add Type:= _
xlExpression, Formula1:="=($B" & _
cell.Row & "=""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
End If
End With
Next
ws.Range("C6").Select


End Sub

It performed as I expected, but I can't say that is what you expect.
--
Regards,
Tom Ogilvy


"BEEJAY" wrote:

Tom:
Thanks so much for the impressively prompt response.
I'm getting a an error: Compile Error: Syntax error on the following:

.FormatConditions.Add Type:=xlExpression, Formula1:="=($B" & _
cell.row & = ""*"")"
As I was inputting the code, it kept on going back to the last = sign, and
indicating
Compile Error, Expected Expression.

Help Pls. (again)

"Tom Ogilvy" wrote:

I assume the worksheet is unprotected when you run the code


Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long, cell as Range

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow


For each cell in ws.Range("C6:C" & ILastRow)
With cell
.Select
if .Locked then
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B" & _
cell.row & =""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
end if
End With
Next
ws.Range("C6").Select

--
Regards,
Tom Ogilvy

"BEEJAY" wrote:

In spite of someones efforts to help me, I am not able to modify or ?? the
following to work on locked cells (only) in the selected range in column C.
It is critical to the application. Will someone please help?

Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow
With ws.Range("C6:C" & ILastRow)
.Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B6=""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
End With
ws.Range("C6").Select

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Color locked cells only in specified range

Tom:
It also works as I expected.
Thanks much.
JFS

"Tom Ogilvy" wrote:

Looks like I had a typo. should have been cell.row & "= ""*"")"

I ran this successfully

Sub AARR()

Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long, cell As Range

ILastRow = ws.Range("B:B") _
.SpecialCells(xlCellTypeLastCell).Row


For Each cell In ws.Range("C6:C" & ILastRow)
With cell
.Select
If .Locked Then
.FormatConditions.Delete
.FormatConditions.Add Type:= _
xlExpression, Formula1:="=($B" & _
cell.Row & "=""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
End If
End With
Next
ws.Range("C6").Select


End Sub

It performed as I expected, but I can't say that is what you expect.
--
Regards,
Tom Ogilvy


"BEEJAY" wrote:

Tom:
Thanks so much for the impressively prompt response.
I'm getting a an error: Compile Error: Syntax error on the following:

.FormatConditions.Add Type:=xlExpression, Formula1:="=($B" & _
cell.row & = ""*"")"
As I was inputting the code, it kept on going back to the last = sign, and
indicating
Compile Error, Expected Expression.

Help Pls. (again)

"Tom Ogilvy" wrote:

I assume the worksheet is unprotected when you run the code


Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long, cell as Range

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow


For each cell in ws.Range("C6:C" & ILastRow)
With cell
.Select
if .Locked then
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B" & _
cell.row & =""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
end if
End With
Next
ws.Range("C6").Select

--
Regards,
Tom Ogilvy

"BEEJAY" wrote:

In spite of someones efforts to help me, I am not able to modify or ?? the
following to work on locked cells (only) in the selected range in column C.
It is critical to the application. Will someone please help?

Dim ws As Worksheet
Set ws = Worksheets("Pricing")
Dim ILastRow As Long

ILastRow = ws.Range("B:B").SpecialCells(xlCellTypeLastCell).R ow
With ws.Range("C6:C" & ILastRow)
.Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=($B6=""*"")"
.FormatConditions(1).Interior.ColorIndex = 4
End With
ws.Range("C6").Select

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
Locked worksheet & hyperlinks (w/ select locked cells unchecked) dgold82 Excel Discussion (Misc queries) 1 July 10th 09 09:42 PM
How do U Color shade Locked and FormulaHidden Cells Kieranz Excel Programming 3 May 23rd 06 12:40 PM
change fill color of a range of cells based on color of a cell? DarMelNel Excel Programming 0 March 2nd 06 06:35 PM
Put comments on a locked spreadsheet even though cells not locked RDP Excel Worksheet Functions 1 September 11th 05 11:59 PM
I want the macros to be locked up when cells are locked up. Ed Excel Programming 6 February 20th 05 01:31 AM


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

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

About Us

"It's about Microsoft Excel"