![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Range Question ??
HYCH
My question is: I have a range from H2:I32, within this range i have values of 1 and 0 spread throughout, is it possible to run a vba macro to check for a 1 and then colour the cell red, i know how to use the 'Pattern.Solid Colorindex and numbers, but am having very little luck with the actual code to check this range, would prefer to have this running as a worksheet change event Hych Steve |
|
|||
|
Re: Range Question ??
I would suggest using conditional formats (formats->Conditional
formatting) If it really needs to be vba though (and it doesn't sound like it does... ) Public Sub colortest() Dim wb As Workbook Dim sht As Worksheet Dim cell Set wb = ThisWorkbook Set sht = wb.Worksheets("Sheet1") For Each cell In sht.Range("H2:I32") If cell.Value = 1 Then cell.Interior.ColorIndex = 1 Else cell.Interior.ColorIndex = 0 End If Next End Sub This actually changes between white and black... but you get the idea |
|
|||
|
Re: Range Question ??
On 28 Nov, 16:47, hall.j...@gmail.com wrote:
> I would suggest using conditional formats (formats->Conditional > formatting) > > If it really needs to be vba though (and it doesn't sound like it > does... ) > > Public Sub colortest() > Dim wb As Workbook > Dim sht As Worksheet > Dim cell > > Set wb = ThisWorkbook > Set sht = wb.Worksheets("Sheet1") > > For Each cell In sht.Range("H2:I32") > If cell.Value = 1 Then > cell.Interior.ColorIndex = 1 > Else > cell.Interior.ColorIndex = 0 > End If > Next > > End Sub > > This actually changes between white and black... but you get the idea thanks hal, Would use Con From, but does have a tendency to make the filesize larger than needed, where as i find Vba macro has less impact on file sizes. Thanks very much Steve |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|