+ Reply to Thread
Results 1 to 4 of 4

Running if statement through VBA on single cell values dependent on selection

  1. #1
    Registered User
    Join Date
    06-21-2014
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2010
    Posts
    11

    Running if statement through VBA on single cell values dependent on selection

    So I am attempting to find a way to work this issue and have not really found any leads on how to go about doing this.

    Basically I have created a button that will change the color and value of cells that are selected. I would like to find a way to create an if statement that will not change the color or value of certain cells in the selected area.

    The problem I have run across is my code works for a single cell selection, but the moment I select more than one cell the if statement allows all of the cells to change. I am unsure how I need to go about properly creating this if statement

    Please Login or Register  to view this content.
    I've attempted Where statements as well but i feel like I'm not completely understanding how to run the if statement in each cell of the selection.
    Last edited by JBeaucaire; 06-30-2014 at 08:20 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Running if statement through VBA on single cell values dependent on selection

    You declared a "Cell" variable, started a LOOP using that cell variable to check each cell of the current selection individually, but then you failed to use the "cell" variable for your color commands:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    06-21-2014
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Running if statement through VBA on single cell values dependent on selection

    Thank you so much!. I felt like it was something real simple I was missing.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Running if statement through VBA on single cell values dependent on selection

    As it appears you've reached a conclusion, I've marked this thread SOLVED for you.
    FYI, this is done through the Thread Tools located above the first post in this thread. Thanks.

+ 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] Data values dependent on selection from dropdown menu
    By atkelly in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-26-2014, 02:09 PM
  2. Replies: 2
    Last Post: 10-07-2013, 11:06 AM
  3. [SOLVED] Code to put today's date in empty cell dependent on selection from drop-down list
    By vickyh1 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-28-2013, 09:09 AM
  4. Replies: 2
    Last Post: 08-25-2011, 07:27 AM
  5. Replies: 2
    Last Post: 02-13-2006, 12:00 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