ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CF in VB Code - Simple Request (https://www.excelbanter.com/excel-programming/328522-cf-vbulletin-code-simple-request.html)

Kevin Baker[_2_]

CF in VB Code - Simple Request
 
Hi Everyone,

Simple (I think)... Would like VB Code to do the following:

If cell F2 is greater than 1 AND cell G2 is blank then change the cell color
to Light Yellow.

Of course I need to work for the entire F column and G column

Thanks,
Kevin



JulieD

CF in VB Code - Simple Request
 
Hi Kevin

this changes the colour of column F, when a value in column F or G changes
to meet the criteria you specified
------
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 6 And Target.Value 1 And Target.Offset(0, 1) < ""
Then '1
Target.Interior.ColorIndex = 36 '2
ElseIf Target.Column = 7 And Target.Value < "" And Target.Offset(0, -1)
1 Then '3

Target.Offset(0, -1).Interior.ColorIndex = 36 '4
ElseIf Target.Column = 6 Then '5
Target.Interior.ColorIndex = xlNone '6
ElseIf Target.Column = 7 Then '7
Target.Offset(0, -1).Interior.ColorIndex = xlNone '8
End If '9
End Sub
-------
to use this code, right mouse click on the sheet tab where you want it to go
and copy & paste it onto the right hand side of the screen - i've put line
numbers at the end of each line so you can fix up any wrapping problems
caused by posting.
--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"Kevin Baker" wrote in message
news:uM1de.726$lt.422@lakeread02...
Hi Everyone,

Simple (I think)... Would like VB Code to do the following:

If cell F2 is greater than 1 AND cell G2 is blank then change the cell
color to Light Yellow.

Of course I need to work for the entire F column and G column

Thanks,
Kevin




Tushar Mehta

CF in VB Code - Simple Request
 
Turn on the macro recorder (Tools | Macro Record new macro...), set
the conditional format through the UI, and turn off the recorder. XL
should give you the necessary code.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article <uM1de.726$lt.422@lakeread02, says...
Hi Everyone,

Simple (I think)... Would like VB Code to do the following:

If cell F2 is greater than 1 AND cell G2 is blank then change the cell color
to Light Yellow.

Of course I need to work for the entire F column and G column

Thanks,
Kevin





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

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