Results 1 to 13 of 13

Problem using a variable that contains text in VBA conditional formatting...

Threaded View

  1. #1
    Registered User
    Join Date
    01-08-2014
    Location
    Scunthorpe, North Lincs, England
    MS-Off Ver
    Excel 2010
    Posts
    12

    Question Problem using a variable that contains text in VBA conditional formatting...

    Hi all you Excel wizards; I am having a problem with a macro that refuses to do as its told! I have looked through other threads but can't find a solution that suits my issue...

    I have a variable "Initials", that picks up a certain cell's contents; the cells contain guess what - initials in plain text - i.e. "BF"

    When I use:

    Columns("E:H").Select '(range I want to format)
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=" & Initials '(with formatting instructions following)
    
    No cells that contain the text "BF" are formatted - when I then look at the conditional formatting rule in the spreadsheet for the range I see from the criteria that is picked up is Cell Value = BF - not "BF" (i.e. quotes are missing)

    How do I wrap quotes around my variable (or do something else) so that it recognizes the text in the cell my variable is allotted?

    I am sure I have overlooked something simple; however, your speedy response will be gratefully received - should you require further information please respond - thx...
    Last edited by TheSaint0001; 01-08-2014 at 11:36 AM. Reason: added code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Using variable in conditional formatting
    By vtxvtx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2012, 11:43 AM
  2. Add Conditional Formatting To Variable Range
    By nsquared in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2011, 03:06 AM
  3. Conditional Formatting for Variable Cells
    By applefritter in forum Excel General
    Replies: 3
    Last Post: 03-24-2011, 03:26 PM
  4. Replies: 9
    Last Post: 03-16-2011, 01:32 PM
  5. Conditional formatting of range of variable length
    By tinkerbelle in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-01-2009, 08:36 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