PC Review


Reply
Thread Tools Rate Thread

color formatting from vbe

 
 
N+
Guest
Posts: n/a
 
      24th May 2008
hi all.. i need to make the macro to format all the cells of my workbook like
this...

if cell is equal to 2 then
paint it red
end if

if cell is equal to 1 then
paint it blue
end if

help me !! byyy
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      24th May 2008
You could use Conditional Formatting, but with VBA:

Sub color_them()
For Each r In ActiveSheet.UsedRange
v = r.Value
If v = 1 Then
r.Interior.ColorIndex = 3
Else
If v = 2 Then
r.Interior.ColorIndex = 5
End If
End If
Next
End Sub

--
Gary''s Student - gsnu200788


"N+" wrote:

> hi all.. i need to make the macro to format all the cells of my workbook like
> this...
>
> if cell is equal to 2 then
> paint it red
> end if
>
> if cell is equal to 1 then
> paint it blue
> end if
>
> help me !! byyy

 
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
Font Color Conditional Formatting/Color Scaling Ryan Microsoft Excel Worksheet Functions 0 4th Mar 2010 06:03 PM
Color formatting =?Utf-8?B?U3BhbmNlaw==?= Microsoft Excel Worksheet Functions 1 21st Nov 2007 01:55 PM
Color formatting with VBA brian Microsoft Excel Programming 3 17th Aug 2006 12:44 AM
Color Formatting =?Utf-8?B?VG9kZCBOZWxzb24=?= Microsoft Excel Misc 8 3rd Apr 2006 10:37 PM
Conditional color formatting entries have wild color. =?Utf-8?B?Sm9obiBHZXllcg==?= Microsoft Excel Misc 0 24th Feb 2006 06:11 PM


Features
 

Advertising
 

Newsgroups
 


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