+ Reply to Thread
Results 1 to 5 of 5

How to write a VBA code for 3 different conditions or Criteria?

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    1

    How to write a VBA code for 3 different conditions or Criteria?

    Hi,

    I am creating an Excel spreadsheet at work, which consists of 2 columns. The 1st column is the AMOUNT PAID TO A SUPPLIER. The 2nd column is the BALANCE REMAINING TO THE SUPPLIER.

    I really need a VBA code for the following condition/ criteria:

    If the AMOUNT PAID TO A SUPPLIER = THE BALANCE REMAINING TO A SUPPLIER THEN THE ROW SHOULD HIGHLIGHT IN
    PURPLE.

    If the AMOUNT PAID TO A SUPPLIER > THE BALANCE REMAINING TO A SUPPLIER THEN THE ROW SHOULD HIGHLIGHT IN BLUE.

    If the AMOUNT PAID TO A SUPPLIER < THE BALANCE REMAINING TO A SUPPLIER THEN THE ROW SHOULD HIGHLIGHT IN RED.

    Can anyone help please? It will be really appreciated!

    Thanks,

    Suraj

  2. #2
    Registered User
    Join Date
    01-17-2014
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to write a VBA code for 3 different conditions or Criteria?

    Try this.....

    Please Login or Register  to view this content.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,897

    Re: How to write a VBA code for 3 different conditions or Criteria?

    1) why VBA while Conditional Formatting will do the work easily?
    2) If (see 1) VBA - thing what should trigger the colouring (a button or a change in a worksheet?)
    3) Go through http://www.excelforum.com/forum-rule...rum-rules.html (anyway worth doing).
    have a closer look on the section:
    Want to get your question answered quickly?
    My favourite part is here:
    Post a WORKBOOK. Nobody wants to type data from a picture or paste text from your post into a spreadsheet as a prelude to helping. To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.
    PS. If you plan to use code as proposed by rbs_logesh try to avoid hardcoding end row numbers (like 65536) - instead use "last used row" - search forum for examples how to detrmine it).
    Last edited by Kaper; 01-20-2014 at 08:50 AM.

  4. #4
    Registered User
    Join Date
    01-17-2014
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to write a VBA code for 3 different conditions or Criteria?

    1. He wants to highlight the entire row. I hope it can not be done by conditional formatting. So that i used VBA.
    2. He can call this function by button or in worksheet change based on his neccessity

    Thanks. I'm new to this forum. I will learn and follow the best way of replies

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,897

    Re: How to write a VBA code for 3 different conditions or Criteria?

    Quote Originally Posted by rbs_logesh View Post
    He wants to highlight the entire row. I hope it can not be done by conditional formatting
    No big deal to do it just with conditional formatting. The rule has to be based on formula, not value.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to write Filter criteria code for hidden ERROR value
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2013, 05:17 AM
  2. I am trying to write an array with multiple if conditions
    By kishoremcp in forum Excel General
    Replies: 7
    Last Post: 01-24-2012, 01:13 PM
  3. I am trying to write an array with multiple if conditions
    By kishoremcp in forum Excel General
    Replies: 1
    Last Post: 01-24-2012, 11:20 AM
  4. how to write a nested if formula with special conditions
    By novice2430 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-19-2009, 08:55 PM
  5. How to write formula with multiple conditions
    By pani_hcu in forum Excel General
    Replies: 1
    Last Post: 06-09-2009, 09:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1