Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Shade cell if No value in offset cell

I am trying to have a cell in Column "E" shaded IF a cell in Column"B" has no value.
I do not want it to pickup all the empty cells in Column "B" as my data stops at Row B59.

I want something like this:

Sub ShadeCell()
With Sheet1
If range("B:B").value = "" and range("B:B").row < 59 then
..activate
activecell.offset(,-1,2).select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
end with

end sub


Can someone assist me to have this work?

Corey...


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default Shade cell if No value in offset cell

Why don't you take conditional format?

choose your cells in Column E (E1:E59) with E1 active, then go to
Format - Conditional Formatting...
There you choose "formula" and enter: =B1=""
And then select a grey background.

hth
Carlo

On Jan 21, 10:31*am, "Corey" wrote:
I am trying to have a cell in Column "E" shaded IF a cell in Column"B" has no value.
I do not want it to pickup all the empty cells in Column "B" as my data stops at Row B59.

I want something like this:

Sub ShadeCell()
With Sheet1
If range("B:B").value = "" and range("B:B").row < 59 then
.activate
activecell.offset(,-1,2).select
With Selection.Interior
* * * * .ColorIndex = 6
* * * * .Pattern = xlSolid
* * End With
end with

end sub

Can someone assist me to have this work?

Corey...


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Shade cell if No value in offset cell

If Conditional Formatting is to be avoided then maybe...

Sub ShadeCell()
Dim rgC As Range
For Each rgC In Sheet1.Range("B2:B" & 59)
If rgC.Value = "" Then
With rgC.Offset(-1, 3).Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
With rgC.Offset(-1, 3).Interior
.ColorIndex = xlNone
End With
End If
Next
End Sub

However, are you sure about your Offset argument, Offset(-1,2) only
goes to column D, so I changed to Offset(-1,3) to affect column E. And
that -1 seems dubious, but I left it alone, so it still affects the
previous row.

Ken Johnson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Shade cell if No value in offset cell

Carlo,
how do "choose your cells in Column E (E1:E59) with E1 active"?



"carlo" wrote in message
...
Why don't you take conditional format?

choose your cells in Column E (E1:E59) with E1 active, then go to
Format - Conditional Formatting...
There you choose "formula" and enter: =B1=""
And then select a grey background.

hth
Carlo

On Jan 21, 10:31 am, "Corey" wrote:
I am trying to have a cell in Column "E" shaded IF a cell in Column"B" has no value.
I do not want it to pickup all the empty cells in Column "B" as my data stops at Row B59.

I want something like this:

Sub ShadeCell()
With Sheet1
If range("B:B").value = "" and range("B:B").row < 59 then
.activate
activecell.offset(,-1,2).select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
end with

end sub

Can someone assist me to have this work?

Corey...



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default Shade cell if No value in offset cell

Sorry for my bad explanation.

Select Range E1:E59
one of the cells should be in a slightly different color, this is the
active cell.
Activecell is always the first cell you selected in the range.
You could also click on E1 and then shift+click on E59 which would
result in the same.

hth
Carlo

On Jan 21, 12:13*pm, "Corey" wrote:
Carlo,
how do "choose your cells in Column E (E1:E59) with E1 active"?

"carlo" wrote in message

...
Why don't you take conditional format?

choose your cells in Column E (E1:E59) with E1 active, then go to
Format - Conditional Formatting...
There you choose "formula" and enter: =B1=""
And then select a grey background.

hth
Carlo

On Jan 21, 10:31 am, "Corey" wrote:



I am trying to have a cell in Column "E" shaded IF a cell in Column"B" has no value.
I do not want it to pickup all the empty cells in Column "B" as my data stops at Row B59.


I want something like this:


Sub ShadeCell()
With Sheet1
If range("B:B").value = "" and range("B:B").row < 59 then
.activate
activecell.offset(,-1,2).select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
end with


end sub


Can someone assist me to have this work?


Corey...- Hide quoted text -


- Show quoted text -


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
shade one cell that will shade multiple cells Walt Excel Discussion (Misc queries) 1 November 17th 09 03:46 PM
Shade Active Cell - Shade the cell the cursor is in only while in Lisa Excel Programming 2 April 17th 07 10:00 PM
auto-hide rows, cell format (# and @), update cell refs, shade cel Mo2 Excel Discussion (Misc queries) 0 April 17th 07 03:44 AM
Simple one? How to shade an offset cell... Kevin Excel Programming 2 May 18th 04 01:31 PM
Need help - how to shade an offset cell....(simple?) Kevin Excel Programming 2 May 18th 04 01:30 PM


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