+ Reply to Thread
Results 1 to 6 of 6

Variables that contain cell formatting

  1. #1
    Registered User
    Join Date
    03-09-2017
    Location
    Bury St Edmunds, England
    MS-Off Ver
    2016
    Posts
    3

    Variables that contain cell formatting

    I'm trying to create a case with IF statements that then format the next cell with values stored in a variable. If I add msgbox ClrGreen it returns the values but I can't see how it apply it to the IF statement. I've tried this with functions and subs and am not getting anywhere. My Case and If's work perfectly but the code is getting quite large and I want to reduce it with variables. Any help would be appreciated.

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 03-09-2017 at 11:09 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,675

    Re: Variables that contain cell formatting

    You cannot use variables like that. You cannot put code into a variable, then expect that code to execute if you just put the variable name on a line.

    Here is a solution using a Sub. You just included a snippet of your code so it doesn't compile.

    Please Login or Register  to view this content.
    Note: I omitted passing Cell to the Sub, and just added it. Make sure you use this version.
    Last edited by 6StringJazzer; 03-09-2017 at 11:38 AM.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-09-2017
    Location
    Bury St Edmunds, England
    MS-Off Ver
    2016
    Posts
    3

    Re: Variables that contain cell formatting

    Thanks for the reply Jeff. Apologies for not including the whole code earlier. Below is the full code with your changes but I'm unable to get this to work. I get a 'Compile error: ByRef argument type mismatch'. Would you be able to take another look please?

    Please Login or Register  to view this content.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,675

    Re: Variables that contain cell formatting

    You have not declared variables. I strongly recommend to everyone that they declare variables. If you declare Cell as Range in your sub then it will compile. I also recommend you declare lRow as Long, Feature As Range,

  5. #5
    Registered User
    Join Date
    03-09-2017
    Location
    Bury St Edmunds, England
    MS-Off Ver
    2016
    Posts
    3

    Re: Variables that contain cell formatting

    Thanks again Jeff. It works perfectly now! Appreciate the help.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,675

    Re: Variables that contain cell formatting

    You're welcome and thanks for the rep! I have marked your thread as SOLVED but in the future you can do it yourself.

    Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

+ 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] Conditional Formatting with variables
    By Aussie1 in forum Excel General
    Replies: 1
    Last Post: 06-04-2014, 05:38 PM
  2. VBA conditional formatting variables
    By charles1239 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-01-2012, 10:22 PM
  3. Conditional Formatting - more than 3 variables
    By mc515 in forum Excel General
    Replies: 2
    Last Post: 03-20-2008, 07:36 AM
  4. Conditional formatting w/ > 3 variables
    By Kearse56 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2007, 09:24 AM
  5. Formatting variables
    By Dan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-14-2006, 01:15 PM
  6. Conditional formatting for more than 3 variables
    By Emile in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-07-2006, 12:30 PM
  7. [SOLVED] formatting variables
    By JT in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-22-2005, 12:20 PM

Tags for this Thread

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