Results 1 to 3 of 3

Add an "or" command to vba

Threaded View

  1. #1
    Registered User
    Join Date
    02-25-2013
    Location
    England
    MS-Off Ver
    2010
    Posts
    27

    Add an "or" command to vba

    Hi, I have a macro that conditional formats a cell depending on the country it contains. What I need though is a way so that a particular colour scheme can apply to more than one country. So basically if A1 = "Sweden" "TRUE "FALSE" can become if A1= "Sweden" or "Ukraine" or "Barbados" "TRUE "FALSE" for example.

    Here is the code:

      Range("A1:ah60").Select
        Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=IF(A1=""Bosnia & Herzegovina"",TRUE,FALSE)"
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Font
            .Color = RGB(0, 0, 0)
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior
            .Pattern = xlPatternLinearGradient
            .Gradient.Degree = 15
            .Gradient.ColorStops.Clear
        End With
        With Selection.FormatConditions(1).Interior.Gradient.ColorStops.Add(0)
            .Color = RGB(0, 0, 225)
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior.Gradient.ColorStops.Add(0.07)
            .Color = RGB(0, 0, 225)
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior.Gradient.ColorStops.Add(0.1)
            .Color = RGB(255, 255, 0)
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior.Gradient.ColorStops.Add(0.13)
            .Color = RGB(255, 255, 0)
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior.Gradient.ColorStops.Add(0.16)
            .Color = RGB(0, 0, 225)
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior.Gradient.ColorStops.Add(0.19)
            .Color = RGB(0, 0, 225)
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior.Gradient.ColorStops.Add(0.22)
            .Color = RGB(245, 255, 255)
            .TintAndShade = 0
        End With
        With Selection.FormatConditions(1).Interior.Gradient.ColorStops.Add(1)
            .Color = RGB(245, 255, 255)
            .TintAndShade = 0
        End With
        
        
    End Sub

    Any help appreciated.
    Last edited by dabaron; 10-05-2018 at 11:50 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 02-05-2019, 12:03 AM
  2. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  3. Adding "Command Button" and "Messages Box" in VBA Macro
    By sanjeevkumarmc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2014, 07:21 AM
  4. Replies: 3
    Last Post: 05-31-2013, 05:16 AM
  5. Create a Command Button to "Save As" and "Close" an Excel Workbook
    By thedunna in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-26-2013, 05:38 PM
  6. How to change a Command Button caption from "Enable" to "Disable"?
    By Infinity in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2007, 12:14 AM
  7. [SOLVED] inserting a conditional "go to" command on a excel "if" function
    By velasques in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-10-2006, 04:20 PM

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