+ Reply to Thread
Results 1 to 6 of 6

Conditional formatting within code

  1. #1
    Registered User
    Join Date
    11-24-2013
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Conditional formatting within code

    Hello

    Is it possible to enter conditional formatting via the code rather than selecting each cell individually?

    For example, for cell D3 I need to enter conditional formatting is formula of =isna(match(long,"worksheetname!$d$1:$d$1200,0))
    And the same for k3, but searching column k instead
    And for r3 etc

    Then for cell G4 for example, instead of searching for "long" I need to search for "big" and this is then repeated four times over four different columns.

    Any ideas? I have at least 60 X 4 occurrences to do..... Code would be far easier ...... If I knew how to do it!!!!

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Conditional formatting within code

    For the first part of your question, use a relative column reference instead of absolute and you can just copy the formatting between columns. i.e. use d$1:d$1200

    For the second part:
    If the long/big/etc is changing on each row, then you could put those words into another column and use OFFSET with COLUMN.
    For example:
    A3 - long
    A4 - big
    A5 - short
    D3 formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Drag this down and you'll get:
    D3 - long
    D4 - big
    D5 - short
    Drag it right and you'll get the same in E3/4/5.


    You can then put this (amended suitably depending on where you put the words) into your larger formula.

    Does that help?
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Registered User
    Join Date
    11-24-2013
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Conditional formatting within code

    That may just do it.......let me have a play! I'm still learning!!

    Daft question..,.within the formula for formatting, =isna(match("long",worksheetname!$d$1:$d$1200,0)) where do I actually put that section for the offset within the formula. Thanks so much

  4. #4
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Conditional formatting within code

    It would replace "long", so something like this:
    =isna(match(OFFSET((D3),0,-(COLUMN()-1)),worksheetname!d$1:d$1200,0))

  5. #5
    Registered User
    Join Date
    11-24-2013
    Location
    Lancashire, England
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Conditional formatting within code

    Amazing thank you x

  6. #6
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Conditional formatting within code

    You're welcome.

    If the above has answered your question, then please mark this thread as [Solved] (instructions in my signature), so that other members/visitors can see that there's a solution now. Thank you.

    If instead you have any follow-up questions, just let us know

+ 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. VBA code instead of conditional formatting?
    By IanF23 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2015, 05:57 PM
  2. [SOLVED] VB Code for Conditional Formatting
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-18-2015, 11:19 PM
  3. [SOLVED] Conditional Formatting by code
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-09-2015, 07:00 PM
  4. [SOLVED] VBA code for conditional formatting
    By Srikanth H N in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2014, 11:51 AM
  5. Conditional Formatting Code - Deletes Wrong Conditional Format
    By RSpecianJr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2010, 10:53 AM
  6. Conditional Formatting with code
    By rlcohen70 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2008, 04:51 AM
  7. vba code + conditional formatting
    By Sharp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2007, 03:23 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