473,698 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional Fomatting (>3 conditions)

6 New Member
Hi
I am trying to change the colour of cells based on the values of 2 other cells but I couldn't get the right VBA code for Excel 2003. Could you please help me with the following conditions:

if valueX<=2 and valueY<=2, green colour

if valueX>=4 and valueY>=4, red colour

otherwise, yellow colour.

There might be more similar conditions, therefore I want to use VB to handle more than 3 conditions.

Many thanks

Prakash
Mar 26 '08 #1
1 970
daniel aristidou
491 Contributor
Hi
I am trying to change the colour of cells based on the values of 2 other cells but I couldn't get the right VBA code for Excel 2003. Could you please help me with the following conditions:

if valueX<=2 and valueY<=2, green colour

if valueX>=4 and valueY>=4, red colour

otherwise, yellow colour.

There might be more similar conditions, therefore I want to use VB to handle more than 3 conditions.

Many thanks

Prakash
TRy using
Expand|Select|Wrap|Line Numbers
  1. Dim num as cell.val
  2. Select Case  num
  3. Case num>2
  4. Cell.color = red
  5. Case num >3 
  6. Cell.Color = blue
  7. end select
  8. Etc
Mar 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

15
2271
by: Max | last post by:
Hi, I'm a perl programmer and am trying to learn PHP. So far I have figured out most of the differences, but have not been able to find out how to do the following: When running through a loop, how can you test two separate conditions against the same $element of an array. For example, this is how I thought it would be done (similar to Perl), but it did not work:
7
3516
by: Guy Hocking | last post by:
Hi there, I have a problem in my ASP/SQL Server application i am developing, i hope you guys can help. I have a ASP form with list boxes populated by SQL tables. When a user selects a value in a list box and submits the form the value is put into a session variable and the relevant page is displayed (in accordance to one of the list boxes). The page is then displayed with the relevant SQL data. So far i have got the
3
5929
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both of them are mentioned in the bug list on the access
3
1723
by: HateSpam | last post by:
I have a field on a form which shows a field with conditional formatting. From this form, it is possible to open another form where the user can update things which will affect the field with the formatting. When this second form closes, it calls a .Requery for the first form. The value in the formatted field updates, but it's formatting does not. What else do I need to do?
2
2964
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not showing or only part of the data in the field displays (i.e. it will display the last name but not the first name or it will display neither). When the conditional formatting is removed it displays all the data as it should be display so the data...
3
471
by: DFS | last post by:
Has anyone figured out how to apply more than 3 conditional formats to a datasheet (or continuous) view, or in lieu of that how to apply more than 3 conditional (based on a name) colors? I saw the Stephan Lebans stuff, but I'm not convinced he can do it either. Thanks
4
14415
by: ApexData | last post by:
In a Continuous form, I want to use Conditional Formatting to change the background color of a date field based on a condition. 1-The color chart in the CF menu option offers limited colors. How can I use the custom colors I need ??? 2-Is Conditional Formatting available in code, so that I can use more than 3-conditions and have more versatility than the Access2k CF menu option offers ???
20
2083
Ericks
by: Ericks | last post by:
I want to apply Conditional Fomatting to a sub form's date control when it's of earlier date than a date in another table (form). I use following code in Expression is: DateDiff("s",DLookUp("","LastMeetingDate"),)>0 but keep getting a syntax error message. Any idea what I'm doing wrong?
1
1760
by: mlgmlg | last post by:
Hello, I have a text box (on a Single Form) that I use to color code milestones based on a value. I use the “Conditional Formatting” tool to format four of the conditions, which works great! Unfortunately, I need an additional two conditions for a total of six. I believe the additional two conditions must be created by using code to accomplish what I need, but I do not have a whole lot of knowledge in coding. I am wondering if someone...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.