PC Review


Reply
Thread Tools Rate Thread

Color locked cells only in specified range

 
 
=?Utf-8?B?QkVFSkFZ?=
Guest
Posts: n/a
 
      13th Mar 2007
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).Row
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      13th Mar 2007
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).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

--
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).Row
> 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 With Quote
 
=?Utf-8?B?QkVFSkFZ?=
Guest
Posts: n/a
 
      13th Mar 2007
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).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
>
> --
> 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).Row
> > 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 With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      13th Mar 2007
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).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
> >
> > --
> > 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).Row
> > > 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 With Quote
 
=?Utf-8?B?QkVFSkFZ?=
Guest
Posts: n/a
 
      14th Mar 2007
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).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
> > >
> > > --
> > > 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).Row
> > > > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the color of a range of cells. Srajes Microsoft Excel Programming 6 25th Jun 2009 05:41 PM
have a range of cells shade a certain color akeshka Microsoft Excel Programming 2 14th Apr 2008 10:07 PM
How do U Color shade Locked and FormulaHidden Cells Kieranz Microsoft Excel Programming 3 23rd May 2006 12:40 PM
change fill color of a range of cells based on color of a cell? =?Utf-8?B?RGFyTWVsTmVs?= Microsoft Excel Programming 0 2nd Mar 2006 06:35 PM
Color Range of Cells halem2 Microsoft Excel Programming 5 18th Jan 2006 01:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 PM.